Support » Fixing WordPress » Expires headers not working on S3

  • I finally got around to setting up a CDN with W3TC, using Amazon S3. So far, everything seems to be working. (The site is here.) The images are being served from the CDN.

    However, when I checked with PageSpeed and Yslow, it still warned me that I needed to set Expires headers for that content, even though I have browser cache enabled in W3TC.

    Here’s where it gets weird. When I look at the images on S3, I can see metadata created by W3TC that sets the appropriate header. For example, for this image, the metadata tab on S3 says “Key: Expires” with a value of “Fri, 04 Jan 2013 16:30:53 GMT”

    But when I look at the image in PageSpeed, it shows only an ETag and no Expires header at all.

    HOWEVER! If I make any change whatsoever to the metadata field on S3, like simply clicking in the field and then clicking “Save”, it appears to write the header properly. Take a look at this image in Page Speed for comparison. The only thing I did was click in the metadata field, then click save.

    So, what do I do? I have way too many images to go through and click each one of them. And I’d like new ones to have an Expires Header set automatically. Any idea why the initial upload to the CDN is setting the metadata value, but that value is not showing up as the appropriate header?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter pull-start

    (@pull-start)

    Anybody out there having this issue? “Expires” metadata not producing a real HTTP header?

    First I don’t recommend using S3 alone, it’s not a CDN. You’ll need to add cloudfront to actually have a CDN, when you do, ditch S3 and just use Origin Pull cloudfront. W3TC can set up the distribution directly from the CDN settings tab for you to make things easy.

    Thread Starter pull-start

    (@pull-start)

    Thanks for the reply Frederick. Since I posted this I switched to Cloudfront, but I am still having issues that seem to be related to W3TC calling for files on the CDN that don’t exist. Since I’ve edited the CSS and JS and changed minify settings several times, I’m assuming that W3TC is calling old versions of the minified CSS and JS, not newly updated ones.

    Have you seen that elsewhere at all?

    Frederick Townes

    (@fredericktownes)

    Are you using the option that adds a query string to URLs so that browser can always have the latest version of files?

    Thread Starter pull-start

    (@pull-start)

    I’m not using that feature. Where can I find it? (I’m on version 0.9.2.4 of the plugin.

    I just changed a couple things on the site, for instance, adding an updated functions.php, new JS and CSS call, etc. Everything seemed to be working fine, as long as I kept clearing the cache. (I keep Firefox open and un-logged-in to WP, so I can see how it looks to a non-admin user.)

    However, as soon as I added the new CSS sheet to the existing minify stack (I’m not minifying JS at all right now) and saved changes, all styles disappeared entirely.

    THere is a new default.include.xxxxx.css.gzip file on the CDN, which I imagine is the right one. The trouble is that no matter how often I flush the caches and clear my own browser’s cache, the page is calling for a non-existent minified CSS file.

    Hope that makes sense…

    Thread Starter pull-start

    (@pull-start)

    OK! I just went to the CDN tab and clicked “Upload minified CSS and JS files” and now it seems to be working!

    Should I always plan on doing that any time I make a change to the minify settings. (ie It won’t automatically upload that stuff to the CDN?)

    W3TC will automatically export changed files for you.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Expires headers not working on S3’ is closed to new replies.