By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,278 Members | 1,359 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,278 IT Pros & Developers. It's quick & easy.

Gzip and caching

Unicron
P: 8
Hi folks, I couldn't find any posts about this issue-

I am using Firebug to examine my page loading. When I call a large JS file, it gets downloaded once and then shows as being cached the next time I go to the page.

For example, it shows "9 requests 100 KB (90 KB from cache)"

However, if I change the JS file to a PHP file with GZIP, it compresses that 90KB file down to 20KB, but never says it pulls it from cache. The Firefox "about:cache" page shows that each time the page loads, the fetch count on that file goes up.

I am wondering- is this gzipped file being repeatedly downloaded, or just checking that the file is still the same? If it is being downloaded again, is there a different header I can send to make it work?

Here is the PHP I am using for the gzipped javascript (see to expire 1 year)

[PHP]
ob_start("ob_gzhandler");
header("Content-type: text/javascript; charset: UTF-8");
header("Content-Encoding: gzip");
header("Cache-Control: must-revalidate");
header("Expires: ".gmdate("D,d M Y H:i:s",time() + 3600*24*365)." GMT");
[/PHP]

Thanks everyone!
Oct 2 '08 #1
Share this Question
Share on Google+
1 Reply


pbmods
Expert 5K+
P: 5,821
Heya, Unicron.

I'm not terribly familiar with how browser cache headers work, but this article might be useful:

http://www.mnot.net/cache_docs/
Oct 2 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.