When I run a page loading test with Firefox’ YSlow, I get an F-rating for adding expiration headers:
For instance expiration headers for my webfonts referenced from Google Webfonts CDN and images stored on Amazon S3 and resources coming from my /assets folder
Is there a way to add expiration headers to assets coming from Google Web Fonts and Amazon S3 ?
It looks like the only assets it has an issue with are the ones coming from your asset pipeline. You can set those header in apache of nginx like so.
# The Expires* directives requires the Apache module
# `mod_expires` to be enabled.
<Location /assets/>
# Use of ETag is discouraged when Last-Modified is present
Header unset ETag
FileETag None
# RFC says only cache for 1 year
ExpiresActive On
ExpiresDefault "access plus 1 year"
</Location>
Then I deleted some images and uploaded them again. But this doesn’t seem to have any effect. Firefox Yslow is still complaining about the expiration headers for my assets coming from Amazon S3
That looks correct. I’m not sure why it’s not adding the headers. Have you tried checking to see if the cache headers do get set on the new images? Also it looks like its complaining about the Expires header. Which is an old header type that used to signify the caching age. Some older browsers and older bots still use this. You can read more about it here. You should be setting both on the images, for backward compatibility.
You can see it above in the nginx config. Also the Etag should be set too.
then I deleted a couple of images and uploaded new ones on the homepage: ‘environ-peeling-kuur.jpg’ and ‘gelaatsverzorging.jpg’
But it doesn’t seem to have any effect, Firefox YSlow keeps telling me that the experiation headers for 8 amazon aws assets are not set (while I expect that would have decreased by 2).