Skip to content

add versioned image urls - #544

Merged
jamesmoore merged 2 commits into
mainfrom
add-versioned-image-urls
Aug 21, 2026
Merged

add versioned image urls#544
jamesmoore merged 2 commits into
mainfrom
add-versioned-image-urls

Conversation

@jamesmoore

Copy link
Copy Markdown
Owner

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:

  • Added the EnableCaching method 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:

  • Updated the ImageFileViewModel to include a version parameter (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.
  • Modified the ImageFileViewModelBuilder to pass the file's last write time as the version parameter when constructing the view model.

@jamesmoore
jamesmoore requested a lite review from Copilot August 21, 2026 16:27
@jamesmoore
jamesmoore marked this pull request as ready for review August 21, 2026 16:29

Copilot AI left a comment

Copy link
Copy Markdown

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 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 EnableCaching helper and applied Cache-Control: public, max-age=31536000, immutable on 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.

Comment thread SDMetaUI/Controllers/ImagesController.cs Outdated
…ror responses

Co-authored-by: jamesmoore <6506748+jamesmoore@users.noreply.github.com>
@jamesmoore
jamesmoore merged commit bdfbea6 into main Aug 21, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants