Browser caching is used to save files on end user browser cache and re use on recurring requests. It significantly improve the page load times. Apache web server provides module mod_expire. Which controls the setting of the HTTP header and for expires and max-age directive of the Cache-Control HTTP header in the server responses.
Setup Expire headers on Apache
Before using this, you must have mod expires module enabled on Apache server. On the Debian based systems (Ubuntu, Debian and Linuxmint) expires module is disabled by default. You can enable this by running the following command:
sudo a2enmod expires
After enabling modules, restart Apache server to load new settings.
Now, Add the below settings to Apache virtual host configuration file, or add this in .htaccess file under your application.
Making changes in .htaccess will will be effective immediately, But if you add above settings in Apache virtual host configuration file, you need to reload Apache server.
In this tutorial, you have learned to enable Apache modules and configure Apache HTTP headers to save files on users browser.