getgrav / grav

Modern, Crazy Fast, Ridiculously Easy and Amazingly Powerful Flat-File CMS powered by PHP, Markdown, Twig, and Symfony

Home Page:https://getgrav.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Grav serving stalled content: Last-Modified ignore modular pages last modification date

drzraf opened this issue · comments

In #2168 someone requested that the template modification be taken into account when computing the Last-Modified header.
It happens that the time computed from this header is based exclusively on the main page last modification time even if has multiple (more recent) children modular pages.

The consequence is that when someone reaches such a Grav page their browser first check Cache-Control: max-age (see #3560) and, if the content is deemed expired, the browser will send a If-Modified-Since header (using the Last-Modified) date.

If any caching-proxy exist between the user and Grav, it's likely to send a 304 Not Modified (because of the wrong Last-Modified date) leading the stale content being served to the users.

The consequence depends on the browsers but I've got reports pointing this pervasive behavior affecting many users (including our own editors).
Some browser vendors may simply not send the If-Modified-Since is loading the URL from the address-bar or from a the Back button, or from a hard-refresh or if the debugger is opened. But most browser regularly visiting production-grade Grav instances are suffering this issue.

I hear what you are saying, and i've certainly seen this scenario, but the problem is how to know what other pages (modular, or even just content from another regular page) and if modifications of these impact the main page. Checking a modified date of every page included in a collection could be time consuming and there is no guarantee that these pages are used in the actual output of the page, they might be for something else entirely.

What i'm saying is I agree it would be great to have this functionality, but i'm not how we could achieve it. Especially when you take into account that most of this logic happens at the Twig level which makes it very hard to intercept and do a calculation like this.

I'll discuss it with @mahagr and see if there's any way to achieve this.