Less files not getting compiled immediately

158 Views Asked by At

I am working on a django application and using less for generating CSS. On my localhost, everything works fine and changing less file updates CSS almost immediately.

However, when I deploy to server (apache2, wsgi), the old css files are rendered for a long time. I was wondering how can I fix this? Is there a way I can forcefully invalidate the precompiler cache so that new CSS files are generated?

Thank you

1

There are 1 best solutions below

2
On

I've been using django_compressor for managing Sass. In my deployment script I use the django_compressor compress offline setting, which generates a new filename for the compressed static files. I started doing this to get around server caching and browser caching problems, and it's been scaling nicely as my static files have gotten larger.

Here's the docs on offline compression or precompression

In my deployment script I run manage.py compress which generates the new file names.

This probably isn't the simplest solution but it's a good time investment to set up.