Mobile app version of vmapp.org
Login or Join
Eichhorn148

: What headers do I need to set to allow my content to be cached without any sort of revalidation for a set amount of time? I'm going cross eyed looking at all the HTTP headers available for

@Eichhorn148

Posted in: #Cache #CacheControl

I'm going cross eyed looking at all the HTTP headers available for controlling the caching of content.

What headers do I need to set I I want content to be cached:


For at most 24 hours (or any time period I choose)
With no re-validation
With no etags


I've realized that browsers are re-requesting my CSS, JS, and images on every page view. I want them to be able to cache these items for some amount of time without checking back in at all with my site.

My server does not support "if modified since" nor "etags". I have implemented a versioning system where the version of the resource is in the file name, so I can cache bust when the files are changed.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Eichhorn148

1 Comments

Sorted by latest first Latest Oldest Best

 

@Phylliss660

The Expires header is the simplest. If you're using Apache you can set this by mime type using mod_expires. In your .htaccess:

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access plus 1 day"
ExpiresByType image/png "access plus 1 day"
</IfModule>

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme