TWIL: Expires Headers in .htaccess for Fonts and Images

This Week I Learned about Expires Headers

This week I learned (TWIL) is a weekly installment containing tidbits our team has learned about search engine optimization, PPC / AdWords, social media marketing, and other aspects of Internet marketing. This week, Jake Bohall discovered the secrets of setting expires headers on font files in .htaccess. Check out what he has to say below in this week’s TWIL!

Credit: The Hangover

Set Expires on font files with headers in .htaccess.

I was working to help speed up a client’s site this week, and was having issues “conquering” page speed insights. In order to fix the “leverage browser caching” issue with some lagging font files, I went to .htaccess to set some expires headers.

Generally, I have plugins running like autoptimize, etc. but in this case, I was just looking for a simple solution to leverage browser caching for font files (ttf, svg, otf, eot, woff, etc.. ), so I did a little research through Stack Overflow and found a nice solution that seems to have done the trick!

See the final code below, as well as some other htaccess code I typically put in place for speeding up a site!

@ditsa — I just put it in seconds.. I could have done “access plus 6 days” instead..

You can set the expires to whatever timing you like, just as long as you are being mindful of if/how content might change. E.g. if you set JS or CSS files to a month, and then change your site without modifying the filename, then your site could look pretty wonky to previous visitors if you’ve changed class names or something and don’t have them referenced in the cached css file.

Hive Marketing Services

Get Started

800-650-0820

Hive Digital can help you get the most out of your website. Simply fill out this form, and we'll get back to you with a free quote. No risk, no obligation.

NOTE: You'll need to have Javascript enabled to fill out this form. We're testing some new spam prevention techniques, and the current iteration requires Javascript to run. Email us via sales@hivedigital.com with your inquiry.

Hive Digital respects your privacy. We will never spam you or sell your information to any third party. Privacy Policy

Get Started

800-650-0820

Hive Digital can help you get the most out of your website. Simply fill out this form, and we'll get back to you with a free quote. No risk, no obligation.

NOTE: You'll need to have Javascript enabled to fill out this form. We're testing some new spam prevention techniques, and the current iteration requires Javascript to run. Email us via sales@hivedigital.com with your inquiry.

Hive Digital respects your privacy. We will never spam you or sell your information to any third party. Privacy Policy