Thursday, July 19, 2012

Re: CachedStaticFilesStorage unavailable in debug mode

Yeah I think CachedStaticFiledStorage totally rocks too. In my case I'm using apache mod wsgi as my development environment, so the appropriate expires headers on the static files are all set correctly. I just can't get the hashing functionality when I run it in debug mode. But I've solved the problem I just subclassed CachedStaticFiledStorage and had my version do the hashing even if DEBUG mode is active. thanks for the help.


On 19 July 2012 10:50, Thomas Orozco <g.orozco.thomas@gmail.com> wrote:

CachedStaticFiledStorage will work, only it will not append the hashes as it usually does and behave like a standard file storage.

The use case for this storage is to set very long expires dates on the static files and rely and their url changing (due to the hash changing ) whenever you change them, which causes a cache refresh for thé end user browser only and systemically when neefed. (which totally rocks)

Now, this means that the webserver (nginx, apache)  must set the appropriate expires headers on the static files.

These won't be set with the development server, and you probably won't bother doing it even if you develop with an actual webserver.

So there's no use for hashes. But they still cause a performance drop. So django just falls back to a standard storage.


I think that if you definitely need it for test just copy it and change it so it works with debug true.

Le 18 juil. 2012 21:39, "Marwan Al-Sabbagh" <marwan.alsabbagh@gmail.com> a écrit :
Hi,
  so as explained in the docs CachedStaticFilesStorage will not be applied if DEBUG setting is set to False. I just wanted to understand why this is the case. I have a development environment and want to use CachedStaticFilesStorage. thanks.

cheers,
Marwan

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment