add versioned image urls - #544
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves client-side image caching by introducing cache-busting, versioned image URLs and by enabling long-lived HTTP caching headers on the image-serving endpoints.
Changes:
- Added a
v=query parameter to thumbnail and full image URLs based on the image file’s last modification time. - Updated the view model builder to compute and pass the file modification “version” into the view model.
- Added an
EnableCachinghelper and appliedCache-Control: public, max-age=31536000, immutableon image endpoints.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| SDMetaUI/Models/ImageFileViewModelBuilder.cs | Computes a version value from the file’s last write time and passes it into the view model. |
| SDMetaUI/Models/ImageFileViewModel.cs | Appends a v= query param to thumbnail/full image URLs for cache busting. |
| SDMetaUI/Controllers/ImagesController.cs | Enables aggressive caching headers for thumb/full image endpoints via a shared helper. |
Suppressed comments (1)
SDMetaUI/Controllers/ImagesController.cs:52
- EnableCaching(httpResponse) is set before verifying the file exists, which means the NotFound/Problem paths can return a 1-year immutable Cache-Control header. Consider only enabling caching for successful file responses.
EnableCaching(httpResponse);
string physicalPath = Base32Decode(path);
if (fileSystem.File.Exists(physicalPath))
{
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ror responses Co-authored-by: jamesmoore <6506748+jamesmoore@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces improvements to image caching and cache busting in the application. It enables aggressive HTTP caching for image endpoints and adds a version query parameter to image URLs based on the file's last modification time, ensuring that clients always receive the latest image when it changes.
Caching improvements:
EnableCachingmethod to set HTTP response headers (Cache-Control: public, max-age=31536000, immutable) for both thumbnail and full image endpoints, allowing browsers to cache images for up to one year. [1] [2] [3]Cache busting for image URLs:
ImageFileViewModelto include aversionparameter (derived from the image file's last modification timestamp) in image URLs. This ensures that when an image changes, the URL changes as well, invalidating the browser cache.ImageFileViewModelBuilderto pass the file's last write time as the version parameter when constructing the view model.