How to Set an Expires Header in Apache
Setting an Expires (or Cache-Control) header in Apache will help speed up your website. I’m running Apache 2.x, and define an expires header for all of the site’s static assets (images, stylesheets, and scripts).
In Apache, mod_expires is a module that allows you to set a given period to live for web pages and other objects served from web pages. The idea is to inform web browsers how often they should reload objects from the server. This will save you bandwidth and server load because clients who follow the header will reload objects less frequently.
Command to enable mod_expires:
To set an expires header, only add the following to the “virtualHost” section of your Apache vhost configuration:
Alternatively, you can add it to your htaccess file in a block. Also, you should enable mod_defalate which will gzip your HTML, CSS, and Javascript
Command to enable mod_defalate:
And add these lines: