30

I'm on a slightly flaky connection and I'm trying to improve my browsing experience with the use of a local proxy. According to my research, however, if I hit 'enter' in my browser on an existing URL, it'll send a Cache-Control: max-age=0 header to the proxy, which will, in turn, make round-trips to the server to revalidate the content.

I don't particularly want this; if the object is stale, the cache will re-fetch it, but if it's not stale I don't see why I'd want the object revalidated every freakin' time. If I suspect the page is old, I've got shift-F5 and I'm not afraid to use it.

So, is there a tunable somewhere behind the scenes in Chrome that'll turn this annoying behaviour off?

24

I have found that if you browse to a page through your back-button or a link, Chrome doesn't send the max-age=0 header and will usually (if the apache server on the other side is configured for caching) use a cached version of the page.

However, when you enter the URL (e.g. www.example.com/abcd/index.html) directly into the address bar and then press Return, Chrome will always send the Cache-Control: max-age=0 header, which circumvents caching.

|improve this answer|||||
  • 1
    This is not an answer, it's a restatement of my question. – womble Feb 5 at 5:13
5

It is possible to modify the headers Chrome sends to a webserver using either userscripts (ala greasemonkey) or extensions. Here is one extension that should work: ModHeader

According to the introduction and screenshot, adding a header such as cache-control max-age=1000 should be relatively straightforward. It also supports domain whitelists to prevent headers from being sent to specific websites. You may need enable certain experiments in chrome://flags for this work.

demo of adding headers

|improve this answer|||||
0

Browsers behave based on the response headers they receive. If the browser receives response headers like

Cache-Control: private
Expires: Thu, 01 Jan 1970 00:00:00 UTC

then, browser would always request with Cache-Control: max-age=0. This usually happens with Tomcat container, where the BaseAuthenticator adds these response headers when the variable disableProxyCaching is true. If you are facing similar issue, you can visit this link for solution.

Hope this helps to a certain extent :)

|improve this answer|||||
0

I'm trying to test caching on my website so need to simulate a 'new user', but of course Chrome sends Max-Age: 0 meaning the server's cache is bypassed so I can't test the server side caching.

What I found worked best for this use-case was in conjunction with Fiddler.

Chrome settings (must keep dev. console open)

enter image description here

and Fiddler:

enter image description here

This isn't good for the OP's issue - but I expect most people aren't currently finding this question due to the exact same problem.

|improve this answer|||||
  • Why would you introduce a separate proxy, when you could use an extension in the browser to achieve the same end result? – womble Feb 5 at 2:37
  • Because a lot of developers already have fiddler running and I like to minimize number of extensions running. It’s just another option. In my situation today I’m testing it then I’m done with it :) (I hope!) – Simon Feb 5 at 2:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.