I have updated my .htaccess file to include the following:
<FilesMatch "\.(css|js)$">
ExpiresDefault "access plus 1 month"
</FilesMatch>
I am trying to tell the client that all css and js wont change for 1 month so they can cache they files.
I have 2 questions,
Since adding that I am now getting a 500 error, the whole .htaccess file is below:
<FilesMatch "*\.(css|js)$">
ExpiresDefault "access plus 1 month"
</FilesMatch>
# BEGIN Compression (DEFLATE)
<IfModule mod_deflate.c>
# Enable compression
AddOutputFilterByType DEFLATE text/css text/javascript application/x-javascript text/html ``text/plain text/xml image/x-icon
<IfModule mod_setenvif.c>
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
</IfModule>
<IfModule mod_headers.c>
# Make sure proxies deliver correct content
Header append Vary User-Agent env=!dont-vary
# Ensure proxies deliver compressed content correctly
Header append Vary Accept-Encoding
</IfModule>
</IfModule>
# END Compression (DEFLATE)
Expires Headers are certain lines of code that tell your browser how long it should keep the cached files from your site. You can add Expires Headers by adding a code such as ExpiresByType image/jpg “access plus 1 month” to your site.
Place all of the resources (such as images, scripts, etc.) that you would like to set far-future expirations for into the static folder and then add an . htaccess file to that folder that includes the expires headers. Place the rest of the resources that you do not want cached into the other folder .
The expires header is an HTTP header that indicates whether it is possible to obtain information on request from the browser cache or if you need to access the server since the page option in the cache is already outdated. This header contains the date and time until the page is available in the browser cache.
Make sure ExpiresActive ON
is set inside of your FilesMatch directive before ExpiresDefault
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With