...at djangosnippets: http://www.djangosnippets.org/snippets/991/
I wanted to be able to use the forever-caching capability of Google Web Toolkit with my own resources, so I wrote this template tag to handle any resource. If the file you want cacheable is a JS or CSS file, it will (optionally) use YUI compressor to compress the file first. It creates a copy of your original file called "LONGMD5SUM.cache.(js| css|png|gif|etc...)". You have to set it up separately, but to get the effect of forever-caching, configure your webserver to cache resources conforming to that name. Different webservers do it differently, of course (I use lighttpd), so that's left as an exercise to the reader. In DEBUG mode, the minification and copying is turned off so you don't get a proliferation of files as you develop. I'm not entirely happy with the way I handle relative vs. absolute paths. It's hard to get a scheme that will work in cacheable and non- cacheable mode using the same pathname. I settled on setting DOCUMENT_ROOT in settings.py to my real document root (one step above MEDIA_ROOT) and using "/media/css/my.css" etc... in the "src" and "href" attributes in the template. I have to strip the leading "/" off to make os.path.join work right, but I have to put it *back* after I strip out DOCUMENT_ROOT and send it as a path to the browser. I think there's a better way to handle this and I'd be interested in hearing how to do that. I hope you find this useful. Comments are welcome! Thanks! Jon Brisbin http://jbrisbin.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---