Site icon Tech Dreams

HTTP Headers: Max-Age vs Expires – Which One To Choose?

Caching of static content like images, scripts, styles on the client browser reduces load on the webservers and also improves end users browsing experience by loading web pages quickly. We can use HTTP headers Expires or Cache-Control:max-age to cache content on client browser and set expiry time for them.

Expire header is HTTP/1.0 standard and Cache-Control:max-age is introduced in HTTP/1.1 specification to solve the issues and limitation with Expire  header. Consider the following headers.

 

Cache-Control: max-age=24560

Expires: Tue, 15 May 2012 06:17:00 GMT

The first header instructs web browsers to cache the content for 24560 seconds relative to the time the content is downloaded and expire it after the time period elapses. The second header instructs web browser to expiry the content after 15th May 2011 06:17.

Out of these two options which one to use – max-age or expires? I prefer max-age header for the following reasons

Related: Amazon S3 Tips: Quickly Add/Modify HTTP Headers To All Files Recursively

cc image flickr:rogue3w

Exit mobile version