To enable caching on Apache web server – simply type the following in on the CLI:
a2enmod expires
With this you can now add caching rules to your Virtual Host:
<FilesMatch "\.(jpg|png|gif|mp4)$">
ExpiresActive On
ExpiresDefault "access plus 1 year"
</FilesMatch>
<FilesMatch "\.(css|js)$">
ExpiresActive On
ExpiresDefault "access plus 1 month"
</FilesMatch>
Your application will need to manage expiring the cached files when things change.