Django-compressor: Offline Compression Error

Created on 25 Sep 2013  ·  6Comments  ·  Source: django-compressor/django-compressor

I have spent a week debugging this (two different separate weeks) and am quite frustrated. I think I have read almost every article/blog post/issue out there, and don't know what to do. I have both a staging server and a production server (each with separate s3 buckets) and this works on staging, but not production, even though the servers (on Heroku) and the buckets are identical.

I have made it so compress tags only show up in the child template. I have removed all template tags from within compress tags (e.g if/else)., meaning I have more compress tags so the if/else statements can be outside the compress tags.

Does anyone have a functioning offline compression set up in production anywhere to look at? With compress offfline=False--there is significant extra load on the server, frequently an extra 300-500 ms delay, which obviously isnt worth it and defeats the whole purpose of this package.

I could really use some help, but basically have no idea what to do at this point, because its the same issue you can read about with hundreds of people in the issue list here, in blog posts elsewhere, and no repeatable solution seems to be being suggested--which is a huge problem for something this crucial to performance and that probably any Django deployment requires.

deployment

Most helpful comment

Last days I was busy resolving the same problem, and here is what was the fix, in case it helps to somebody.

In one of the templates, where the issue was reproducible, I was using context. During offline compression there is no access to the context, that's why the key generated during offline compression, and the one from the response cycle are obviously going to be different.

Try to isolate the parts of JavaScript where you are relying on context to another block, which is outside the compress tag.

Hopefully this information helps somebody.

All 6 comments

The same here. Seems django_compressor's COMPRESS_OFFLINE makes more problems than solves. I can't get it to work because receive such messages:

OfflineGenerationError: You have offline compression enabled but key "%s" 
is missing from offline manifest. You may need to run "python manage.py compress".

Same here :/

Can't get offline compression to work. Keep getting OfflineGenerationError.

So i made sure i run the following during each deploy on all web servers

python manage.py compress --force
python manage.py collectstatic

That should refresh the manifest.json file. Also i make sure the name of manifest file is different with each push. Like add a version number. manifest_%s.json
I use the latest git commit hash id to plugin %s. So during deploy it does a git pull, compress, collectstatic, creating new minified/aggregated css/js with a new manifest.json file.
And then i restart apache. So it should all be smooth.

Also i made sure collectstatic does not call --clear, to delete old static/* media.

Make sense?

ok I have exactly the same problem.
Anyone is running this offline from S3 in a reliable manner?

Last days I was busy resolving the same problem, and here is what was the fix, in case it helps to somebody.

In one of the templates, where the issue was reproducible, I was using context. During offline compression there is no access to the context, that's why the key generated during offline compression, and the one from the response cycle are obviously going to be different.

Try to isolate the parts of JavaScript where you are relying on context to another block, which is outside the compress tag.

Hopefully this information helps somebody.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

camilonova picture camilonova  ·  7Comments

jvc26 picture jvc26  ·  4Comments

ghost picture ghost  ·  20Comments

polmuz picture polmuz  ·  20Comments

bobort picture bobort  ·  20Comments