English 中文(简体)
Explanation for expires header
原标题:

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

  1. 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?

  2. 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.

问题回答

Using a secure session may indeed cause a problem with caching.

For security many browsers do not cache SSL data except during the SSL session. When the browser or tab is closed the SSL cache is flushed out.

Firefox has a config option to control this. I don t know about IE. It s also possible that there is some Cache-Control header that will override this behavior.

The Cache-Control header is, I believe, HTTP/1.1 and you should use it as well as Expires. Cache-Control offers more features for controlling the cache.





相关问题
What to look for in performance analyzer in VS 2008

What to look for in performance analyzer in VS 2008 I am using VS Team system and got the performance wizard and reports going. What benchmarks/process do I use? There is a lot of stuff in the ...

SQL Table Size And Query Performance

We have a number of items coming in from a web service; each item containing an unknown number of properties. We are storing them in a database with the following Schema. Items - ItemID - ...

How to speed up Visual Studio 2008? Add more resources?

I m using Visual Studio 2008 (with the latest service pack) I also have ReSharper 4.5 installed. ReSharper Code analysis/ scan is turned off. OS: Windows 7 Enterprise Edition It takes me a long time ...

Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

热门标签