Skip to content

Fix Last-Modified header on archive pages - #2042

Merged
sy-records merged 4 commits into
php:masterfrom
mattstauffer:mes/fix-last-modified-at
Oct 24, 2026
Merged

sy-records merged 4 commits into
php:masterfrom
mattstauffer:mes/fix-last-modified-at

Conversation

@mattstauffer

@mattstauffer mattstauffer commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

TL:DR: The 2026 archive page is sending a Last-Modified header based on when 2026.php (the template file) was last modified, not based on when there is actually new articles. This PR fixes that.


We ran into a local cache issue on the archive pages:

https://www.php.net/archive/2026.php sends a Last-Modified header based on the mtime of the 2026.php script file. But new articles are data (news entries), not edits to that file, so publishing one never the file's mtime and therefore doesn't advance Last-Modified, which means it's currently been set to August 10 since the last modification of that file.

image

A returning browser then revalidates with If-Modified-Since set to that frozen date, always matches, and gets 304 Not Modified. That means the browser keeps showing the stale archive forever. Only a hard refresh (which omits If-Modified-Since) reveals new articles.

This is all about how the origin emits Last-modified and how the browsers process it, and has nothing to do with the CDN.

So, the fix:

Set Last-Modified to the newer of the most recent article's publish time or the page's file mtime. This way, both new articles and template edits bust the local cache. I extracted this into a news_archive_last_modified() helper in layout.inc and applied it to 2026.php.

@mattstauffer mattstauffer changed the title Fix Last-Modified at on Fix Last-Modified at on archive pages Oct 23, 2026
@mattstauffer mattstauffer changed the title Fix Last-Modified at on archive pages Fix Last-Modified header on archive pages Oct 23, 2026
@naderman

Copy link
Copy Markdown

LGTM, assume this would fix the local cache issues indeed

@sy-records sy-records left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks

@sy-records
sy-records merged commit b9464d1 into php:master Oct 24, 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