• Resolved vladimirbauer

    (@vladimirbauer)


    Hello,

    I have a website on wpengine with this plugin installed. Now I have a problem with caching some images. Here is the response headers for one problematic image:

    accept-ranges: bytes
    content-length: 99
    content-type: image/png
    date: Fri, 29 Mar 2019 08:22:24 GMT
    etag: “5c094d80-63”
    last-modified: Thu, 06 Dec 2018 16:25:36 GMT
    server: NetDNA-cache/2.2
    status: 200
    vary: Accept
    x-cache: HIT

    As you can see expiration header not specified. I have enabled this plugin, also I added this in htaccess but again nothing:
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg “access plus 1 month”
    ExpiresByType image/jpeg “access plus 1 month”
    ExpiresByType image/gif “access plus 1 month”
    ExpiresByType image/png “access plus 1 month”
    ExpiresByType text/css “access plus 1 month”
    ExpiresByType application/pdf “access plus 1 month”
    ExpiresByType text/x-javascript “access plus 1 month”
    ExpiresByType application/x-shockwave-flash “access plus 1 month”
    ExpiresByType image/x-icon “access plus 1 year”
    ExpiresDefault “access plus 2 days”
    </IfModule>

    # One year for image files
    <filesMatch “.(jpg|jpeg|png|gif|ico)$”>
    Header set Cache-Control “public”
    </filesMatch>
    # One month for css and js
    <filesMatch “.(css|js)$”>
    Header set Cache-Control “public”
    </filesMatch>

    I’m also using CDN for these images, could that be connected? Should I do something else to set expiration headers?

Viewing 1 replies (of 1 total)
  • Plugin Author Ethan Kennedy

    (@ethankennedy)

    Hey Vladimir!

    Unfortunately, as those assets are served from the server on Nginx, the plugin isn’t able to manipulate the headers displayed to the end user.

    CDN assets are by default stored for 24 hour hours, and I believe the browser should be expiring the images based on the last modified value included in the response header.

    Turning up the cache on the CDN should be possible in a request to support (or maybe it could be something WP Engine should just do), but the browser should store those images until that last modified date is updated.

    If you’re looking to invalidate the cache, I’d recommend tagging files you want to change with a version, like “?v1” at the end of the url, since that will break the cache and force both the browser and CDN to revalidate the asset. Otherwise, they should update eventually as the CDN picks up the new version, and the browser sees the last modified change.

Viewing 1 replies (of 1 total)
  • The topic ‘Leverage browser caching – expiration not specified’ is closed to new replies.