HTML and CSS Reference
In-Depth Information
Prevent Caching
Apply cache control headers so that rapidly changing pages are always loaded fresh from the server.
HTTP/1.1 200 OK
Date: Sun, 08 Apr 2007 20:58:58 GMT
Server: Apache/2
X-Powered-By: PHP/5.2.0
Cache-control: public
Last-Modified: Fri, 03 Dec 2004 11:53:03 GMT
ETag: "6548d4-30a9e-c7f4e5c0"
Content-Length: 325
Content-Type: text/html; charset=UTF-8
HTTP/1.1 200 OK
Date: Sun, 08 Apr 2007 20:58:58 GMT
Server: Apache/2
X-Powered-By: PHP/5.2.0
Cache-control: no-cache
Last-Modified: Fri, 03 Dec 2004 11:53:03 GMT
ETag: "6548d4-30a9e-c7f4e5c0"
Content-Length: 325
Content-Type: text/html; charset=UTF-8
Motivation
Not everything should be cached. You do want to be careful before blindly allowing caching. Done wrong,
caching can deliver stale information or expose users' private data. Stock prices need to be updated from
second to second. So do sensor readings from laboratory equipment.
Or perhaps you simply want better user statistics. You want to know how many users are seeing your ads
without having to guess how many users equate to each AOL proxy server. Cacheable pages will measure fewer
hits than uncacheable pages. Marking pages as uncacheable inflates, and usually more accurately reports, site
traffic.
Potential Trade-offs
Uncacheable pages place much higher loads on a server. Worse yet, the effect is multiplied at times of high
traffic, such as an online store the weekend before Christmas or any site that gets dugg. If you're turning
caching off purely to improve hit counts and user tracking, be ready to turn it back on again if traffic spikes.
Ideally, you should build in automatic governors that notice the traffic is spiking and reenable caching without
manual intervention.
Mechanics
One way to prevent caching is to make all requests go through POST, because POST requests are never cached
(at least not by decent clients and proxies). However, that's the wrong solution. Using POST to prevent caching
is like using SAP to run a mom-and-pop candy store. It's much too big a solution for too small a problem, and
consequently it will cause more problems than it solves.
Search WWH ::




Custom Search