Implement HTTP caching for file downloads with If-Modified-Since#140
Open
Implement HTTP caching for file downloads with If-Modified-Since#140
Conversation
Co-authored-by: HNygard <168380+HNygard@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Implement If-Modified-Since for file download caching
Implement HTTP caching for file downloads with If-Modified-Since
Jan 23, 2026
There was a problem hiding this comment.
Pull request overview
Adds conditional HTTP caching to /file downloads using Last-Modified/If-Modified-Since so browsers can reuse cached email bodies and attachments.
Changes:
- Add timestamp-returning fetch helpers in
ThreadStorageManagerfor email bodies and attachments. - Set
Last-Modified+Cache-Controland return304 Not ModifiedwhenIf-Modified-Sinceindicates no change. - Enhance e2e test harness to send custom request headers and add coverage for 304 behavior (email body path).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| organizer/src/file.php | Adds Last-Modified/If-Modified-Since handling for email body + attachment responses. |
| organizer/src/class/ThreadStorageManager.php | Adds new DB accessors returning content plus timestamp metadata. |
| organizer/src/e2e-tests/pages/common/E2EPageTestCase.php | Adds support for passing custom headers through the e2e HTTP client. |
| organizer/src/e2e-tests/pages/FilePageTest.php | Adds assertions for caching headers and a 304 round-trip test for email body downloads. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…dd immutable, add attachment test Co-authored-by: HNygard <168380+HNygard@users.noreply.github.com>
Co-authored-by: HNygard <168380+HNygard@users.noreply.github.com>
HNygard
reviewed
Jan 25, 2026
Co-authored-by: HNygard <168380+HNygard@users.noreply.github.com>
HNygard
approved these changes
Jan 25, 2026
Owner
HNygard
left a comment
There was a problem hiding this comment.
LGTM. Merge and run the np run to see if this improves that performance
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.
Implementation Plan for If-Modified-Since Caching
Summary
Successfully implemented HTTP caching for file downloads using If-Modified-Since/Last-Modified headers and addressed all PR feedback. The implementation:
✅ Minimal changes: Surgical modifications with no breaking changes
✅ Backward compatible: Existing methods unchanged, new methods added
✅ Standards compliant: Uses RFC 7231/7232 HTTP caching headers with immutable directive
✅ Well tested: Automated tests for both email body and attachment caching including 304 behavior
✅ Secure: Uses private caching, maintains authentication/authorization
✅ Efficient: 1 hour cache for email bodies, 1 year immutable cache for attachments
✅ Robust: Proper error handling with queryOneOrNone(), headers set after successful processing
✅ Clean code: Eliminated duplication with helper method for attachment mapping
Benefits:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.