tags:

views:

36

answers:

2

Hi: In rails, if I import a css file or javascript file, the url will be like this

<script type="text/javascript" src="some.js?<ETag here>"></script>

if I upgrade the some.js the etag will be changed, so my browser can cache the static resource smartly and update the cache when necessary.

Is there a way to do it in django?

+1  A: 

Maybe django-static can help you on this ..

django_static is a Django app that enables as various template tags for better serving your static content. It basically rewrites references to static files and where applicable it does whitespace optmization of the content.

By making references to static content unique (timestamp included in the name) you can be very aggressive with your cache-control settings without ever having to worry about upgrading your code and worrying about visitors using an older version.

This solution is, as <jldupont> pointed out, one, which does not relate to HTTP ETags.

The MYYN
A: 

Besides django-static mentioned by The MYYN, these projects will do what you need and also contain other highly useful features like compression and concatenation:

django-compress

django_compressor

Van Gale