Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

and to tell browser to reload an object (and/or a page... everything on the site) only if is been modified since last visit time??? htaccess, httpd.conf... have you a ready directive right for my case? Thank You very much

share|improve this question

2 Answers 2

up vote 2 down vote accepted

html5boilerplate.com includes a well commented .htaccess file that has many standard settings you should consider. Among them are reasonable settings for expiring the content.

Here's the documentation on mod_expires.

share|improve this answer
    
Awesome links Matthew. Thanks a lot for sharing! –  Ramon Araujo Mar 15 at 3:47

Note that Last-Modified headers are weak cache headers. The current preference is to use Cache-Control headers.

Google has a good article on this.

Optimize Caching

Expires and Cache-Control: max-age. These specify the “freshness lifetime” of a resource, that is, the time period during which the browser can use the cached resource without checking to see if a new version is available from the web server. They are "strong caching headers" that apply unconditionally; that is, once they're set and the resource is downloaded, the browser will not issue any GET requests for the resource until the expiry date or maximum age is reached.

Last-Modified and ETag. These specify some characteristic about the resource that the browser checks to determine if the files are the same. In the Last-Modified header, this is always a date. In the ETag header, this can be any value that uniquely identifies a resource (file versions or content hashes are typical). Last-Modified is a "weak" caching header in that the browser applies a heuristic to determine whether to fetch the item from cache or not. (The heuristics are different among different browsers.) However, these headers allow the browser to efficiently update its cached resources by issuing conditional GET requests when the user explicitly reloads the page. Conditional GETs don't return the full response unless the resource has changed at the server, and thus have lower latency than full GETs.

I recommend using either Cache-Control or Expires headers as needed since they are strong cache headers. Some systems will ignore Last-Modified dates.

You can then use a tool like curl or http://redbot.org to check the headers.

share|improve this answer
    
FWIW: "weak" is something that Google made up. Expires is a totally inappropriate header for resources that do not expire. Some resources may be modified, but not at some expiration date. Google's point is that Last-Modified requires a conditional GET, whereas Expires allows the browser cache to skip the GET altogether. –  Dancrumb Jul 29 at 18:14
1  
The term weak is simply semantics. The point is that using Last-Modified headers in the absence of other caching instructions leaves the cache period up to the HTTP client. If a resource has not been modified since the Last-Modified date, the resource should be considered fresh. In contrast, when using an Expires or Cache-Control header the origin can set an explicit freshness period. –  jeffatrackaid Jul 29 at 19:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.