Mobile app version of vmapp.org
Login or Join
Angela700

: Another way to force non-caching This is the HTTP header I typically use to ensure that an image is not cached. And the reason why I do this to a select few images is because I have an

@Angela700

Posted in: #Cache

This is the HTTP header I typically use to ensure that an image is not cached. And the reason why I do this to a select few images is because I have an image application integrated in my site and caching the images would make the application broken.

I use the following:

cache-control: no-cache,no-store,must-revalidate


I tested in Opera 11.6 and Firefox 17.0.1. Opera 11.6 works fine, however Firefox 17.0.1 decides to cache the image anyways until I force-reload the page, and this is even after I choose to clear all caches and cookies in that browser.

I remember there is a pragma: no-cache back in the day, but at the rate that technology is advancing, I wonder if that line is still effective today.

Can I somehow tweak cache-control to make firefox behave, or will I need to include pragma as well? And I'm looking for a solution so that all browsers can understand that no caching means no caching.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Angela700

1 Comments

Sorted by latest first Latest Oldest Best

 

@Candy875

Here's my entire htaccess from a site, works well on various browsers though didn't test it extensively however it satisfies pagespeed ;-)

You'd just have to edit the parts necessary for you and put in file types for the time spans.

And perhaps it is more than you require but based on the last part of your question:


but at the rate that technology is advancing....


Thought it may be useful for you and others.

# 1 YEAR
<FilesMatch ".(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$">
Header set Cache-Control "max-age=29030400, public"
</FilesMatch>

# 1 WEEK
<FilesMatch ".(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>

# 1 week
<FilesMatch ".(txt|xml|js|css)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>

# NEVER CACHE
<FilesMatch ".(html|htm|php|cgi|pl)$">
Header set Cache-Control "max-age=0, private, no-store, no-cache, must-revalidate"
</FilesMatch>

SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/css
text/plain text/xml text/javascript application/x-javascript application/x-httpd-php
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
BrowserMatch bMSI[E] !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip
Header append Vary User-Agent env=!dont-vary


Here's where parts of this came from. askapache.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme