Skip to content

Add content hash as query string to static file paths #758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

reakaleek
Copy link
Member

@reakaleek reakaleek commented Mar 17, 2025

Closes #703

image

@Copilot Copilot AI review requested due to automatic review settings March 17, 2025 15:02
@reakaleek reakaleek requested a review from a team as a code owner March 17, 2025 15:02
@reakaleek reakaleek self-assigned this Mar 17, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds functionality to append a content hash query string to static file URLs, which aids in cache busting for static assets. Key changes include:

  • Introduction of a StaticFileContentHashProvider to generate and cache content hashes.
  • Updates to view models and HTML writer to incorporate the new content hash into static file URLs.
  • Removal of duplicate embedded file provider code from the documentation web host.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Elastic.Markdown/IO/EmbeddedOrPhysicalFileProvider.cs Consolidates file provider logic for embedded and physical resources.
src/Elastic.Markdown/IO/StaticFileContentHashProvider.cs Introduces a new provider to compute a content hash for static files.
src/Elastic.Markdown/Slices/_ViewModels.cs Updates view models to include a function for retrieving content hashes.
src/Elastic.Markdown/Slices/HtmlWriter.cs Integrates the content hash provider into the layout rendering process.
src/docs-builder/Http/DocumentationWebHost.cs Removes redundant provider implementation in favor of shared logic.
src/Elastic.Markdown/Slices/Index.cshtml Passes the new content hash function to the view for static asset URL construction.

Copy link
Member

@Mpdreamz Mpdreamz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit, great work!

@reakaleek reakaleek enabled auto-merge (squash) March 17, 2025 16:29
@reakaleek reakaleek merged commit ae99836 into main Mar 17, 2025
10 checks passed
@reakaleek reakaleek deleted the feature/add-content-hash-as-query-param-to-static-files-url branch March 17, 2025 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: Add content hash to asset file names
2 participants