What is the best way to set the future for images with Django?

I am using django-compress with great future expiration for my css and js files. It works great.

I would like to do something similar for other static content (images, flash, etc.). I can set the distant future on this content, but I have to manually rename the files when they change.

Is there a better way to handle this?

+5
source share
2 answers

With django-compressyou see CSS and JS as dynamic files - this is normal. However, other files are static - and Django really does not want to serve them. They must be served directly by Apache or another web server.

Apache -

<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
</FilesMatch>

.htaccess Apache.

:. . , . , URL-, , (, ) . , , Apache YAHOO!

IMO . :

  • ( ) URL- , HTML-. URL URL , . /media/3/header.png, /media/header.png.
  • mod_rewrite URL- , .. /media/3/header.png /media/header.png. .
+4

URL- - , .

. Django , expire_tag ( ):

<link rel="stylesheet" type="text/css" 
  href="{{ MEDIA_URL }}{% expire_tag "css/reset.css" %}" />

Apache.

+6

All Articles