I need help regarding implementing the .htaccess file in my angular project which doesn't have the backend integration yet at all. That is why I can't make http headers to send the 'Cache-Control
' header as i want it to.
Like currently I'm working on the lighthouse optimization of the project where I need to cache the cacheable resources like images stylesheets and scripts in order to reduce round trip to the server again & again. Currently I'm getting 70+ resources that needs to be cached but I can't cache each single one seperately, so I decided to go with .htaccess mthod in order to simply defining in one place and getting effect everywhere.
The problem is, despite placing .htaccess file in root directory(src/.htaccess) and adding it's reference in angular.json's assets array, I'm unable to see the desired effect i.e. cache control header is vanished or sometimes showing 'Cache-Control: no-cache
'.
Help is appreciated, Thanks in advance.
Here's my code sample:
<IfModule mod_headers.c>
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=31536000, public"
</FilesMatch>
</IfModule>