APACHE 2 - Cache control configuration
The goal of this change is to add the following line(s) into the headers of your file(s):
Cache-Control: public, max-age=31557600
This change allows us to cache your files for the above specified time (in seconds)
How to do that?
1) Enable mod_headers module (it is usually disabled by default). In Debian and Ubuntu Linux distributions use the following command:
For Linux distributions or other Unix systems without additional module handling infrastructure add the following line to web servers httpd.conf:
LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so
2) Then we need to tell the web server to send specific headers for those specific situations.
Open your virtual server configuration:
For example: If you want to cache all your .pdf and .jpg files for a year, add the following code into your configuration.
<FilesMatch "\.(pdf|jpg)$"> Header set Cache-Control max-age=31557600 </FilesMatch>
Please, make sure that you don't have any duplicate headers before we proceed to the last step.
3) For the configuration to take effect restart your web server with following command: