django-jimmypage icon indicating copy to clipboard operation
django-jimmypage copied to clipboard

Cache is cleared on every launch

Open andybak opened this issue 13 years ago • 3 comments

At the end of cache.py you call clear_cache()

This means the code runs on import and therefore everytime Django starts - even for management commands.

Is this necessary? I use several frequent cron tasks that run via management commands and I'm looking to minimise the number of times I start from a cold cache.

If I can safely remove this line then my cache will spend considerably longer warm.

andybak avatar Oct 03 '12 13:10 andybak

Indeed, I see no reason why that line couldn't be removed.

yourcelf avatar Oct 03 '12 13:10 yourcelf

I've thought of a slight caveat...

I've just edited some templates and restarted. I now realise I also have to reset the cache too.

So it needs to be clearly documented somewhere that a manual cache clear is needed in these situations. And probably a management command to make easy to do from the shell.

andybak avatar Oct 15 '12 21:10 andybak

Of course - there is also the scenario when you use something like django-compress with far-future cache headers.

Normally django-compress will change the compressed filename so your compressed static files are fresh.

However - with JimmyPage you'll get the cached version of the page with the urls for the old static files.

So basically you need to increment the cache every time you change your static files. You probably also need to handle user-uploaded stuff. If you use something like django-filebrowser you'll want to listen for the file upload signal and potentially increment your cache then

andybak avatar Oct 18 '12 16:10 andybak