Some questions about caching
I am using apache webserver for a django application. How, do I set caching for images and css? I ran a webpagetest on my website, and it says "expiration not specified" for css and images. But, when I use Firebug, for css files, firebug show开发者_如何学Gos requests and response headers, as well as in cache tab it shows
Device: Disk
and no requests are shown for images. So, I am a bit confused. Whats happening here.?
I usually have this config for django static files in my apache vhost :
Alias /static/ "/home/django/projectName/static/"
<Directory "/home/django/projectName/static">
Order allow,deny
Allow from all
Options +FollowSymLinks
ExpiresActive On
ExpiresByType image/gif A1209600
ExpiresByType image/jpeg A1209600
ExpiresByType image/png A1209600
ExpiresByType text/css A1209600
ExpiresByType text/javascript A1209600
ExpiresByType application/x-javascript A1209600
<FilesMatch "\.(css|js|gz|png|gif|jpe?g|flv|swf|ico|pdf|txt|html|htm)$">
ContentDigest On
FileETag MTime Size
</FilesMatch>
</Directory>
Remember to not use the django static.serve view in production.
Also use Ctrl+Shift+R to do a full reload in Firefox (override cache)
精彩评论