I have a joomla application working on Apache.To improve site performace we have written a .htaccess file to root of the application with setting a far future expires header to all the static content. As desired first time the files load in fresh with 200 status code. when again click on the same link many of the files are served directly from cache. I need explanation for two things
When i press f5 then a number of files load with 304 status code however i expected them to be coming directly from cache without hitting the server for a status header?
When i close the browser and come back to the same page again i see the same thing happening a number of files load with 304 status code although i thought they will load directly from the browser cache?
I understand that 304 also serves file from browser cache but i want to avoid the header communication between servers as my static files wont ever change. Also i want to add that my requests are over a https connection does that create any issue.
Browsers have algorithms for sending requests for cached content, based on the expires time. Usually, content with a far future header will never be reloaded like you expect. But, hitting reload or F5 ignores this and forces a page reload of all page content.
What you want to do to test this is put your cursor back in the address bar (ALT-d on Win) and hit Enter. This is like re-visting the page and the browser should behave like you expect.