0

I did a lot of research before posting my question, but none has worked for me. If I run a Google PageSeed test, Google is telling me to cache my fonts that stored on the server. I added a line for the fonts with an expiry date. Compression is enabled for all content types using cPanel. Please can you have a look at my code and tell me if I did everything properly or if it needs to be tweaked.

Thanks in advance!

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType text/css "access plus 14 days"
ExpiresByType text/xml "access plus 0 seconds"
ExpiresByType text/javascript "access plus 14 days"
ExpiresByType application/x-javascript "access plus 14 days"
ExpiresByType image/ico "access plus 14 days"
ExpiresByType image/jpg "access plus 14 days"
ExpiresByType image/jpeg "access plus 14 days"
ExpiresByType image/gif "access plus 14 days"
ExpiresByType image/png "access plus 14 days"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType text/html "access plus 14 days"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"
ExpiresByType application/x-font-woff "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType application/json "access plus 0 seconds"
ExpiresByType application/rss+xml "access plus 1 hour"
ExpiresByType application/atom+xml "access plus 1 hour"
</IfModule>
## EXPIRES CACHING ##
  • It's unclear what question you're actually asking, or what the "nightmare" is that you're referring to. What is happening, and in what way does it differ from what you want/expect to be happening? – Rich Bowen Sep 30 '16 at 17:16
  • Hi Rich, I am asking for someone who deals with .htaccess often to look at my current code and let me know if I am properly caching my site contents and fonts. Thank you. –  Sep 30 '16 at 17:20
  • It looks reasonable to me, but I suppose the best answer would be to try it, and see if the PageSpeed results are more what you are looking for. – Rich Bowen Sep 30 '16 at 17:22
  • This is what I am currently using and Google PageSpeed keeps giving me errors for some fonts and JavaScript files not having a valid expiration date. –  Sep 30 '16 at 17:24
  • Oh, I see. I thought you mean that this was the configuration that PageSpeed recommended you move to. Could you perhaps post the actual messages that PageSpeed is telling you? – Rich Bowen Sep 30 '16 at 17:35
  • Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network. Then it said, Leverage browser caching for the following cacheable resources and it showed all of my fonts with (2 days) at the end of each one. –  Sep 30 '16 at 17:49
  • Ok, try the solution proposed here: http://stackoverflow.com/questions/13429540/setting-expire-headers-for-fonts-not-working – Rich Bowen Sep 30 '16 at 18:31

0 Answers0