The behavior of the browser cache can be controlled with the appropriate HTTP headers either individually or by file types.
For Apache webserver (ie at our webhosting) is one of the caching options to set using of the mod_expires by adding of the relevant rules in a file .htaccess.
- A31536000 is the value indicating how long the file stored in the browser cache in seconds. After this value, the files marked as Expired and when you load the page again files are downloaded from web server.
- ExpiresDefault the value of other non-defined files and setting up their time to load.
- image/jpg the type of cached file, here is chosen according to php file type that you want to cache.
As an alternative, you can still use the following version. This version does not only compression but provides additional caching files.
In case that this code will not work with our htaccess, so move web to directory domains/yourdomain.tld and move there. htaccess with this code and possibly other additional rules given by the site manufacturer.
Tested settings of .htaccess, which includes compression:
The correct page caching, processing speed and other tests you can try by using these tools: