Tag Info

Hot answers tagged

15

It might come from 60 * 60 * 24 * 7 * 4 * 12 = 29030400 where each month consists of exactly 4 weeks.


10

Using the GET-style versioning, from a blank cache multiple URLs - e.g. style.css?v=123 and style.css?v=456 - would return the same content. However I can't see this would be problematic, especially since you'd only link to one at a time. I think you'll find the GET-style much easier to maintain. You don't need separate files: just change the URL and ...


7

First, don't get rid of the ETag like Yahoo says, unless you're using a server farm/cluster. As long as the same file always returns the same ETag when it hasn't changed, then it's a very useful directive. As for other headers, Yahoo's best practices suggests to set a far future Expires header for static files, use Cache-Control for dynamic content. However ...


6

According to Google's Make the Web Faster, pages with query parameters are not cached by many HTTP proxies. Most proxies, most notably Squid up through version 3.0, do not cache resources with a "?" in their URL even if a Cache-control: public header is present in the response. To enable proxy caching for these resources, remove query strings from ...


5

What happens when multiple sites refer a css/js having same name. If they are served from different URLs then the browser will consider them to be different resources and fetch both. What happens when sub-domains refer a same css/js If they are served from different URLs then the browser will consider them to be different resources and fetch ...


5

One option is to send them through a PHP script and have that script out caching headers for you. It accomplishes the same thing with only a little extra overhead for having to have PHP serve the image as a proxy. Example: HTML: <img src="/images/img.php?img=someimage.png"> PHP: <?php $filename = $_GET['img']; $file = '/path/to/file/' . ...


4

See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.3: The max-age directive on a response implies that the response is cacheable (i.e., "public") unless some other, more restrictive cache directive is also present. It's conceivable (likely?) that there are proxies in the wild which break this but since the only failure mode could be ...


4

I'm using a small script combined with a .htaccess rule. Basically, the script takes the file modification timestamp and adds it to it's name (in the web page), while the .htaccess rule redirects the file with the timestamp in the name to the corresponding file from the hdd. I took this from the Particletree blog, here: ...


3

The easiest thing for you is to bypass your cache. This is usually done by pressing Ctrl + F5. There are some variances by browser and you can check on this and see how to completely clear the cache at this Wikipedia page on 'Bypass your cache'. If you opt to completely clear your cache after changes are made to the site this will probably work best for ...


2

This stackoverflow answer tells you everything you need to know.


2

The proper way to do this is to use the HTTP Vary header, like this: Vary: Referer Note that you can't actually tell the browser to automatically use the cached copy for all requests from the "same forum", for two reasons: first, the browser has no idea what constitutes a "forum", and second, even if you defined "same forum" as, say, "same domain", the ...


2

Can server break clients' cache settings? Not with HyperText Transfer Protocol - the client always has the option to clear his or her cache and or otherwise ignore the Expires/max-age value and force a new request. Is there any way (I guess not) to break the client's cache settings (even the homepage is cached)? HTTP clients (I tested with ...


2

The expires header is related to the page, not fragments of it. Lets go over the basics. You send HTML to the browser, all of it or a stream, doesn't matter for the example. The browser receives it and starts parsing it. At the same time, once it starts parsing, all the other linked files are called, like images, css, js, etc. Some parallel connections ...


2

When "Expires" and "Cache-Control" headers are not specified, but a "Last-Modified" header is specified, browsers have to guess at how long they should keep the document in cache. Some browsers do use algorithms that let the page remain in cache for a day or more. Google caching best practices guide states: Last-Modified is a "weak" caching header in ...


2

There is no ideal length. It all depends on how often this content changes for you (and the files usually cached should not change often). I'm not in front my the code for my personal website but that content rarely changes so I have it set to be a week or two IIRC. If your content changes on a daily basis then a 24 hour expiration seems appropriate. ...


2

If you put <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> <meta http-equiv="Pragma" content="no-cache" /> <meta http-equiv="Expires" content="0" /> between your <head> tags, this should force the browser to not cache anything in most browsers.


2

This is normal for dynamic pages. An ETag is a unique identifier for that version of a particular file. The web server can automatically set ETags for static files (html, css etc.), because it can work out when their contents were last changed by looking at the file's last modified time (and some other attributes). There's no way for the web server to know ...


1

I have not used them for a long time, but if you are talking about the cache control header they set when serving content from their CDN, it gets pulled from your source. So for example if you have a pull with the cache control header of max-age 10s then the CDN will copy that. (same goes for cloudfront). The only CDN i am aware of which lets you ...


1

When you have a dynamic site (like WordPress) you should also activate the CloudFlare Railgun so that you get the maximum benefit out of the service. A lot of WordPress "pages" may not be cached by CloudFlare, especially if they change frequently (like an archives page). If your site falls into that category, Railgun may help you out.


1

It seem it tells browser that the cache expires after 1 year, 31461276 seconds means 1 year. More details in this post: EXPIRES VS. MAX-AGE


1

Since you have access to the core configuration file, it would be preferable to write it directly in there, under a directory section like so: <Directory /var/www/data> ExpiresByType application/xml "access plus 24 hours" Header set Cache-control "max-age=86400, public" </Directory> If you really want to use an .htaccess file, make sure ...


1

I believe it is because the browser is not sending a If-Modified-Since during the Request, right? Correct. Do I need to change something in the initial Response headers to make 304s happen? Yes. If you compare original response headers for those resources that have 304 response code on subsequent requests, you will notice: All of them located in ...


1

Ah! I want Cache-Control: private. See the tutorial here: http://www.mnot.net/cache_docs/#EXPIRES


1

The best way is to set a max-age directive in the cache-control header. Specifically: Cache-control: public,max-age=2592000 2592000 is the number of seconds you wish the file to be cached for (in this example it is 30 days ie 60x60x24x30). Do note however, that many users visit websites with empty caches, so downloading all those files in the first place ...


1

Of course it is possible. Try sending these headers in your PHP code: Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Expires: Tue, 1 Jan 1980 00:00:00 GMT The Expires header can have any valid date in the past (preferably quite few years back, in case system time on that PC is set in the past as well). ...


1

Both will work equally well as a query string is considered part of the URL and by changing it you are in effect changing the name of the resource thus causing the browser to fetch a new copy of the file. I say use whichever method is easier for you to maintain.


1

The browser will retrieve the latest version if the browser cached version has expired. It will not do an HTTP GET request until that happens. This is intended behavior, because you want the speed of not having the delay of testing if there's a newer version. This, and a way around it, has been explained in the questions you refer to. Amazon CloudFront will ...


1

Does the disk.enable and memory.enable set to false override the true setting of use-cache? From the mozillaZine link, this would be a reasonable assumption. "This [use-cache] preference controls whether to cache files ... either in memory or on disk." - and if neither memory or disk caching is enabled then it would be reasonable to assume the page ...


1

"Every time I visit the web page" Because I don't think this does disable the cache in IE - in fact I don't think you can completely disable the cache in IE?! I think this setting does literally what it says... it "Checks for newer versions of stored pages every time I visit the webpage". It could check for a newer version by requesting just the ...


1

I use the following: ExpiresActive on ExpiresDefault "access plus 24 hours" ExpiresByType image/jpg "access plus 1 months" ExpiresByType image/gif "access plus 1 months" ExpiresByType image/jpeg "access plus 1 months" ExpiresByType image/png "access plus 1 months" ExpiresByType text/css "access plus 1 months" ExpiresByType text/javascript "access plus 1 ...



Only top voted, non community-wiki answers of a minimum length are eligible