Mobile app version of vmapp.org
Login or Join
Shakeerah822

: Why don't browsers respect cache headers for initial page request? I'm scratching my head a bit on this. A Drupal site I run is setting appropriate cache headers that should indicate that the

@Shakeerah822

Posted in: #Cache

I'm scratching my head a bit on this. A Drupal site I run is setting appropriate cache headers that should indicate that the page can be cached for 15 minutes. However, every time I hit the page it always sends a GET request instead of loading the page from the cache.

I'm not forcefully refreshing the page each time, which I assume would indicate to the browser I want to flush the caches. I don't have any developer mode cache busting enabled.

Is this just the default behavior of browsers, or am I missing something obvious? Here's the request/response headers from hitting my homepage from FireFox dev tools:

NOTE/EDIT: Some people have suggested this was related to the Expires header being in the past. However Cache-Control overrides anything in Expires, as described in RFC 2616, Sec 14.9.3. Drupal includes this to disable caching on older HTTP 1.0 clients, which don't support the more advanced Vary header that Drupal needs for proper caching.

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Shakeerah822

3 Comments

Sorted by latest first Latest Oldest Best

 

@Dunderdale272

In addition to the other answers, the Expires header is in the past, that is also one reason browsers won't cache the page.

10% popularity Vote Up Vote Down


 

@Smith883

You have a Vary: Cookie,Accept-Encoding header in the response. That pretty much means that if the proxy (including your browser) wanted to cache this page it should be prepared to cache a new version for every possibly modified cookie vlaue (or changs in accept-encoding). Especially, it would have to keep a record in the first place of the cookies as they where sent in the request as a distinguishing criterion. I can imagine that either the browser denies this if the cookie is too large (and hence unlikely to be repeate), or it denies it i order to avoid cookie information being leaked via the cache content, or simply the cookie content gets changed on every call.

10% popularity Vote Up Vote Down


 

@Murray432

In CMS programs some pages require interaction with the database to display the dynamic content specific to the users request. The entire page can't be cached or it wouldn't show the correct content to the user.

An example of this in practice is an eCommerce shopping cart / checkout page. Since the page looks different every time there's no way to cache it fully. Without knowing more about the specific page it's difficult to know if the page you are referencing requires database involvement.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme