For more detailed description go to http://betterexplained.com/articles/how-to-optimize-your-site-with-http-caching/

There are different methods of caching.

1. Last modified: If the file has been modified since the create date stamped by the local machine, then the file is downloaded again.

2. ETag: Each file gets an unique identifier. If the same file has different ETags then it is time to download that file again!

3. Expires: You set the expiration date for the file. Server is queried only if the files are expired.

4. Max-age: Max age sets the time after which the files expire. For example, Max-age of 86400 means the file will expire in 1 day.

Apache server already takes care of Last modified, ETag cases. For Expires or Max-age, edit the .htaccess file.

Header add "Expires" "Mon, 28 Jul 2014 23:30:00 GMT"
Header add "Cache-Control" "max-age=31536000"

Advertisements