Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

We store our images on S3 and our performance has been incredibly slow. This morning we turned on CloudFront in hopes that our performance would increase. When I analyze our performance with Google's Dev Tools or YSlow, our site is still slow. Both tools recommend I set expire times so browsers cache the images. I looked in our .htaccess file, mod_expires is turned on with the following rules:

<IfModule mod_expires.c>
 Media: images, video, audio

  ExpiresByType image/gif                 "access plus 1 month"
  ExpiresByType image/png                 "access plus 1 month"
  ExpiresByType image/jpeg                "access plus 1 month"
  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"
</IfModule>

Why are our images not being cached by the browser?

share|improve this question
1  
What actual response headers are your server sending and what values is it setting them to? i.e. Cache-Conrol, Date, ETag, etc...... You can use a tool like Fiddler2 to help you capture that data. –  Mike May 2 '13 at 15:37
    
@Mike - I couldn't use Fiddler2 since I am on Mac but I did download Charles. This may sound crazy but the response header size was 0 bytes (the request header was 212bytes). Does this make sense? –  hugo May 2 '13 at 16:55
    
Install firebug to catch the headers response, works on mac just fine. –  bybe May 3 '13 at 19:41
1  
Why are you editing an htaccess file on your server when the images are all stored on S3? –  DisgruntledGoat May 22 '13 at 15:34
add comment

migrated from programmers.stackexchange.com May 2 '13 at 15:46

This question came from our site for professional programmers interested in conceptual questions about software development.

1 Answer

You'll need to add the cache control headers using the S3 console as your Apache .htaccess only affects locally stored files.

Within the S3 console, go to the Properties -> Metadata section for each file you want to change Add Cache-Control, Expires & Last-Modified headers with appropriate values

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.