Add <FilesMatch> tag to your conf file

<IfModule mod_ssl.c>
<VirtualHost *:443>
	...
	 # Add Cache-Control headers
	<FilesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
	    Header set Cache-Control "max-age=604800, public"
	</FilesMatch>
	...
</VirtualHost>
</IfModule>

Run config test command

apachectl configtest

If there is an error Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration, mod_headers module might not be enabled in your Apache server. To enable the mod_headers module, you can use the a2enmod command:

sudo a2enmod headers

After enabling the module, restart Apache for the changes to take effect:

sudo systemctl restart apache2

Now you can see the cache control header on your browser’s network inspector

Untitled