简体   繁体   中英

How to set expires tags on images that are on a CDN

My site runs on Apache and I have set expires headers in my .htaccess file like so:

<ifmodule mod_expires.c>
<FilesMatch "\.(ico|jpg|jpeg|png|gif|swf)$">
ExpiresActive On
ExpiresDefault "access plus 1 year"
Header append Cache-Control "public"
</FilesMatch>
</ifmodule>

This works great for images that come from my domain. However, 95% of my images are hosted on a cdn called CDN77 , which runs on Nginx.

When I run Yslow on my site, it says that all the images being served from CDN77 do not have expires set. I have also confirmed the expires header is not set for those images by viewing the headers in LiveHTTP (Firefox headers viewer plugin).

CDN77 has said they have no way on their end to configure this.

Any thoughts or ideas as to how to set the expires for the images served from the cdn?

Change your CDN. First of all, they SHOULD allow clients to create exceptions for headers and nginx has a very elaborate configuration set for that. Secondly, the default mode should be to copy response headers from the upstream server (you), and only change or add headers that is specific to the CDN, like the host header, server header and strip any cookie headers you may be sending.

You're not able to set expiry headers on files that are hosted on CDN77. If you require custom cache headers, you'll need to contact their support department.

Expiry headers will be applied to all files on your CDN. It's not possible to apply different expiry values to indiviudal files or specific file types.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM