{"id":564,"date":"2012-04-14T13:53:22","date_gmt":"2012-04-14T13:53:22","guid":{"rendered":"http:\/\/www.sitekickr.com\/blog\/?p=564"},"modified":"2012-04-14T13:53:22","modified_gmt":"2012-04-14T13:53:22","slug":"expires-header-dependent-content-types","status":"publish","type":"post","link":"https:\/\/www.sitekickr.com\/blog\/expires-header-dependent-content-types\/","title":{"rendered":"Expires header and dependent content-types"},"content":{"rendered":"<p>I generally set expire headers for CSS, JS and images according to Google&#39;s page speed recommendations, which at time of writing is one month. This may or not be a good practice, depending how often you update your CSS, JavaScript and\/or images. It generally isn&#39;t the end of the world if a user visits your site and loads cached versions of the various assets that make up your site.<\/p>\n<p>However, where problems may start to creep up is when you have different expiration lengths for different content types. To illustrate this by example, let&#39;s say you have the following Expires header directives in your Apache config:<\/p>\n<p><code>ExpiresActive On<br \/>\n\tExpiresByType image\/png A86400<br \/>\n\tExpiresByType text\/css A604800<br \/>\n\t<\/code><\/p>\n<p>For IIS users, this essentially translates to setting Expires headers for PNGs 1 day from now, and CSS files 1 week from now.<\/p>\n<p>Let&#39;s say a user visits your site, the browser pulls in a caches the PNG and CSS files appropriately. Now, you make a change to a sprite background image, which is loaded via your CSS file.<\/p>\n<p>After 1 day, the new PNG sprite image will be loaded into the user&#39;s browser, but the CSS has not been updated. If you changed the position of the images in your sprite, the corresponding CSS changes would not be refreshed in the user&#39;s browser, leading to somewhat unexpected results.<\/p>\n<p>For this reason alone, it always makes sense to ensure that content types which depend on one-another are always set to expire at the same time.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I generally set expire headers for CSS, JS and images according to Google&#39;s page speed recommendations, which at time of writing is one month. This&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"amp_status":""},"categories":[41],"tags":[43,167],"_links":{"self":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/564"}],"collection":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/comments?post=564"}],"version-history":[{"count":1,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/564\/revisions"}],"predecessor-version":[{"id":565,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/564\/revisions\/565"}],"wp:attachment":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/media?parent=564"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/categories?post=564"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/tags?post=564"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}