Enhance cache writing with last modified timestamp#40
Enhance cache writing with last modified timestamp#40diplix wants to merge 1 commit intogetkirby:mainfrom
Conversation
add $page->modiefied() timestamp to cache files. this way the webserver can return the actual `last-modified` date (instead of the cache write date), when serving cached files.
|
hm, i think i have to work on this more. since some pages or templates are not modified, if if they change, this might lead to strange effects. i.e. my overview page, that liste recent articles in reverse chronological order, was not reladed, because the browser thought (rightfully so), that the page was modified long ago and does not need to be reloaded. this can be worked around by only including certain templates, but that is not generalizable. so please don’t merge this PR until i had more time to think about it. |
|
I've converted it to a draft. Feel free to change it again as soon as you feel that it is ready. |
|
I had the same thought reading your PR description. We would basically need to make a dynamic list of all models that are used in the response and use the latest modified date from all of these models. It would be possible to auto-detect used models in the Kirby core (e.g. by logging when a content field of the respective model is returned and therefore likely to be printed). But this is out of scope of Staticache as the plugin cannot collect this information. Dynamic Kirby page responses (without using Staticache) don't contain the |
add
$page->modiefied()timestamp to cache files. this way the webserver can return the actuallast-modifieddate (instead of the cache write date), when serving cached files.Description
by adding
cache files get an accurate modified date, tested on my site:
before:
ubuntu@kirby:/var/www/kirby$ curl -I https://wirres.net/articles/der-buchhalter-und-ein-baum HTTP/2 200 last-modified: Thu, 27 Nov 2025 12:47:15 GMT etag: "9a94-64492e9a3ab02" accept-ranges: bytes content-length: 39572 vary: Accept-Encoding x-content-type-options: nosniff cache-control: no-cache content-type: text/html date: Thu, 27 Nov 2025 13:43:28 GMT server: Apache/2.4.58 (Ubuntu)after
ubuntu@kirby:/var/www/kirby$ curl -I https://wirres.net/articles/der-buchhalter-und-ein-baum HTTP/2 200 last-modified: Sun, 16 Nov 2025 02:57:52 GMT etag: "9a94-643ad6586cc00" accept-ranges: bytes content-length: 39572 vary: Accept-Encoding x-content-type-options: nosniff cache-control: no-cache content-type: text/html date: Thu, 27 Nov 2025 13:43:50 GMT server: Apache/2.4.58 (Ubuntu)