Note that with Apache the ETag is calculated from the number of the inode, the filesize and the last-modified time of the resource. This can lead to the same resource being fetched multiple times when it is served by multiple webservers (load balancing). That is because the same resource will have different inode-numbers on different filesystems. You can fix that by telling Apache to calculate the ETag from the size and last-modified time of the resource, only:
yes I think Lighttpd is similar, but that is not an issue here as I am using only 1 webserver.
It all goes fine when I do a normal reload (F5), but when I do a shift-reload (Ctrl+F5) then I see multiple requests for the same file (mainly s.gif). It seems if FireFox adds new requests to the queue even if a request for the same file is already outstanding.
Perhaps it is not a huge problem, as it will only affects new users to the website (or users who haven't visited for a while).
Still wondering if other people see the same with FireFox, or that is a web server configuration problem after all.
AFAIK, shift-reload reloads the page without using the cache at all. If the cache is entirely bypassed, then you're going to see the same resource downloaded multiple times. I suggest using regular reload. If you are seeing issues where some resources in the page are stale, either configure expire headers to expire immediately (explicit expires header), or change "browser.cache.check_doc_frequency" to "1" in about:cache.
If you want to simulate a new site experience, just use the "Clear Recent History" menu option to clear all cookies and the entire cache.
It really should not load the same resource multiple times.
Bypassing the cache should reload all resources sure, but if a page references http://foo.com/s.gif twenty times, the browser will only make one HTTP request for it. To do otherwise is pathological behaviour and should be reported to the browser manufacturer.
So my Firefox behaves as Joeri explains, with Ctrl+F5 cache is completely bypassed and there are multiple request for 1 file. I agree with Animal that behaviour should be considered a bug. Did one of you test if you see the same in Firefox?
Condor, no I didn't disable cache, I think those request headers are related to Ctrl+F5. If I do a normal F5, I don't have those headers.
I think I have most of it is clear now. Thanks for all your help. However, a related problem is how to get rid of the validation requests? The "two-trees" example has 20 requests, most of them for data that hardly anytime changes. So it could have a far-in-the-future expires date, while updates are controlled with folder/filename versioning. The template I'm working on has currently around 60 initial requests. To validate each file is a waste of http connections.
I have tried to use pre-check and post-check in the Cache-Control header, but no success. If I have the following response header, validation still takes place on reload:
An explanation of browser caching as I understand it (please correct me if I'm wrong):
Basic cache principles:
- Last-Modified or Etag must be set to enable caching
- Once cached, Expires or Cache-Control:max-age set your expiration date (the latter overrides the former)
- Before the expiration date is reached, the browser will not request the file from the server
- After the expiration date is reached, the browser will do conditional gets (validate requests)
Some other tidbits:
- Cache-Control: "no-store" / "no-cache" prevent caching by the browser, "private" says it can be cached by the browser, "public" says it can be cached by the browsers and proxies. Getting fancy with Cache-Control (using anything besides "no-cache" and "public") can get you into trouble because there are browser bugs and proxy bugs related to these headers.
- "Cache-Control: no-cache" is the only correct way to prevent caching. Dynamic languages (e.g. PHP) implicitly send this header.
- Pragma headers are deprecated and should not be used
- If no expiration date is specified, the browser will assume one based on the browser caching settings. You don't want this, because you don't know in that case whether the browser will send requests to the server or not.
So, as recommendations you get:
- Always include Last-Modified and/or Etag
- Always include Expires and/or Cache-Control: max-age headers
- Either set expires in the past (Expires: -1) to ensure freshness of resources in the browser cache
- Or adapt your deployment so new versions are deployed at different URL's, and set expires far into the future. In that case, browsers will not request updated versions until the expiration date is reached, so you must always change URL's to force fresh downloads.
Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..."