Caching With Expires Headers

Jan 6, 2016

Caching is the process of storing data for future use in the cache’s memory. The stored data is used to serve the same data even faster for future requests. On the web we can store our websites CSS, JavaScript, Images, fonts and many more file types to the browsers cache. The browser won’t request the same file over and over again from the server if the file is stored in the cache. Configuring browser caching can be done within your .htaccess file on Apache servers using Expires Headers. You can modify the code below to increase the length of time the files are stored and the types of files that are stored.

Implement and Audit

As always, it’s best to audit the performance of your site once you implement new code. Some file types can be cached longer than others if they don’t change regularly where as files that do change regularly, like stylesheets and JavaScript files, should be cached for a shorter amount of time.