2

I've noticed something interesting while monitoring the network communications between my browser and server. It has something to do with caching.

Say I have a CSS file http://domain.com/main.css (used in unsecured pages), which can also be accessed via https://domain.com/main.css (used in secured pages).

  1. When I first load an unsecured page, the CSS file gets a 200 OK. When I reload the page (or go to another unsecured page), I get a 304 Not Modified.
  2. When I go to a secured page for the first time, the CSS file from the https source gets a 200 OK. And when I reload the page (or go to another secured page, I get a 304 Not Modifie.
  3. When I return to the unsecured page, the CSS file still gets a 304 Not Modified.
  4. When I return to the secured page, the CSS file gets a 200 OK. What happened to the cached copy? How can I make it cached?
StackOverflowNewbie
  • 39,403
  • 111
  • 277
  • 441

1 Answers1

1

This might answer your question. It might be the case that your website defines this resource as non cacheble by defining this :

Cache-Control   private, must-revalidate, max-age=0

for example ( when accessing https://www.google.com/ncr) causing your browser not to cache it. Do you have Fire-bug\Fiddler or anything similar to view the response headers?

Community
  • 1
  • 1
Scis
  • 2,934
  • 3
  • 23
  • 37
  • My .htaccess has this: `ExpiresByType text/css "access plus 10 years"` and my response headers has the expiration as: `Expires:Thu, 22 Sep 2022 22:25:51 GMT`. Since it is redundant to specify Expires and Cache-Control, I only use Expires. – StackOverflowNewbie Sep 24 '12 at 22:30
  • Can you please paste the whole header (Response & Request)? – Scis Sep 25 '12 at 07:36
  • Never mind. I was reading Firebug incorrectly. It was saying 200 OK even though it got the resource from cache. – StackOverflowNewbie Sep 25 '12 at 08:00