How do I stop Chrome sending Cache-control: max-age=0 when I hit enter?
Solution 1
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.
Solution 2
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.
Related videos on Youtube
Comments
-
user1836103 over 1 year
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?
-
Admin over 2 yearsA workaround for hitting the same URL multiple times in a row and allowing the cache to work is to bookmark the page, then click the bookmark instead of using the refresh button or hitting Enter on the URL.
-
-
user1836103 about 4 yearsWhy would you introduce a separate proxy, when you could use an extension in the browser to achieve the same end result?
-
Simon about 4 yearsBecause 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!)
-
user1836103 about 4 yearsThis is not an answer, it's a restatement of my question.
-
Jon Lorusso almost 4 yearsIt appears that chrome does not set
Cache-Control: max-age=0
if you load a new tab (vs. reloading the current tab). -
user1836103 almost 3 yearsThis is a terrible idea.
-
kevinpo over 2 yearsThe "or a link" is the key here. If you are requesting the same URL multiple times in a row, Chrome apparently assumes that you don't just want the page to stay the same, so it doesn't use the cached version. If you go to a different page and then back (even by manually entering the original URL), it will allow the cached version to be used.