ramow Posted November 21, 2008 Share Posted November 21, 2008 I am trying to optimize the delivery of my javascript files. I am using the "Header" mod_header directive in the httpf.conf: Header add Expires "Mon, 28 Jul 2014 23:30:00 GMT" env=VERSIONED_FILE Header add Cache-Control "max-age=315360000" env=VERSIONED_FILE As you can see, I am setting the expires and Cache-Control in order to make sure that the browser won't ask for the file again. I am using Firefox. Summary: the first time the browser get the file my server sends back the special infinity Expires/Cache-Control. in the header BUT my Firefox always request the file again with a soft refresh. The time to send another request and get a 304 code back is a wasted precious time. How can I solve this problem? Ultimately I want the browser to respect the Expiry date and cache control I have set. I know that not all browser respect those value but as long as IE and Firefox are concerned they do respect that by their default settings. SO WHAT's HAPPENING HERE???!? Please help!!! --Rami Here is the firebug output: #1: -------------------------------------------------------------------------------------------------- HTTP/1.0 200 OK -------------------------------------------------------------------------------------------------- Response Headers Date Fri, 21 Nov 2008 02:50:33 GMT Server Apache Last-Modified Wed, 19 Nov 2008 04:59:15 GMT Etag "9e8436-3f9-45c03ac774ec0" Accept-Ranges bytes Content-Length 1017 Expires Mon, 28 Jul 2014 23:30:00 GMT Cache-Control max-age=315360000 Keep-Alive timeout=15, max=100 Connection Keep-Alive Content-Type application/x-javascript Request Headers Host ############## User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4 Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language en-us,en;q=0.5 Accept-Encoding gzip,deflate Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive 300 Connection keep-alive Pragma no-cache Cache-Control no-cache After a soft refresh. (F5 and NOT ctrl+F5) #2 -------------------------------------------------------------------------------------------------- HTTP/1.0 304 Not Modified -------------------------------------------------------------------------------------------------- Response Headers Date Fri, 21 Nov 2008 03:06:28 GMT Server Apache Last-Modified Wed, 19 Nov 2008 04:59:15 GMT Etag "9e8436-3f9-45c03ac774ec0" Accept-Ranges bytes Content-Length 1017 Expires Mon, 28 Jul 2014 23:30:00 GMT Cache-Control max-age=315360000 Content-Type application/x-javascript Request Headers Host ############## User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4 Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language en-us,en;q=0.5 Accept-Encoding gzip,deflate Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive 300 Connection keep-alive If-Modified-Since Wed, 19 Nov 2008 04:59:15 GMT If-None-Match "9e8436-3f9-45c03ac774ec0" Cache-Control max-age=0 Quote Link to comment https://forums.phpfreaks.com/topic/133606-caching-issues-and-unnecessary-browser-requests-that-would-trigger-a-304-respon/ Share on other sites More sharing options...
kevintynfron Posted November 21, 2008 Share Posted November 21, 2008 Hi ramow, I've just been/still going through the same kind of thing. What I found was that a soft refresh (F5) requests far more things than I expected. Using a navigation link on the web page made things behave as expected. i.e. hitting F5 when viewing the home page requested items with far future expires headers, whereas clicking on a link to the home page and bringing it up that way saw everything behave as I expected, and not request the items with expires headers. I have no idea why, but that's what I saw. See if you get the same. Cheers, Kevin Quote Link to comment https://forums.phpfreaks.com/topic/133606-caching-issues-and-unnecessary-browser-requests-that-would-trigger-a-304-respon/#findComment-695204 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.