Favicon ?!
Any “good” website comes with a favicon, that little picture near the URL bar in your web browser. I’ve noticed recently that for mine, it couldn’t be cached by web browsers and that neither was it compressed as you may notice on that webpagetest.org.
So let’s solve that quickly !
Set the MIME type
First of all, I have no clue why, but Apache2 does not recognize .ico correctly, so you have to set the MIME type by yourself, let’s do it:
If you do not specify that binding, the following steps won’t work !
Caching
Now let’s activate the expires module if it’s not already done:
And let’s add our caching rule:
I set the caching time to one year since I don’t change frequently my favicon, it’s up to you.
Compressing
The deflate module allows Apache2 to compress stuff, here we’ll first activate it:
We need to configure it now:
Last but not least, restart Apache2:
Result
Let’s run the test once again at webpagetest.org !
And the favicon is no more within the “not compressed” nor “not cached” section:
I do agree that it’s just the favicon who cares, but you can use that configuration for other kind of assets, such as pictures, scripts, stylesheets, …