5
votes

I'm having some trouble getting django compressor to work with CloudFront. I'm running the offline compress command to generate my compressed files and the manifest.json file. After this, I am then running collectstatic to upload the compressed files to my S3 bucket.

These static files are then served from CloudFront, so my settings look something like this:

STATIC_ROOT = ''
STATIC_URL = 'http://<my-cloudfront-domain>/somebucket/'

STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'

COMPRESS_OFFLINE = True

The problem is, CloudFront is serving an older version of manifest.json, meaning compressor is throwing an OfflineGenerationError.

Even with a cache backend in place, I'm worried that my manifest file will be incorrect if the cache server is for offline / flushed for whatever reason.

Am I missing something here to ensure I don't run into the OfflineGenerationError?

1
did you find a solution. same issue here. - Nathan Keller
I'm also having this problem, but I fail to understand why compress would access the manifest.json via the static URL instead of using the default file storage; if it did the latter, S3 would be accessed directly and there'd be no caching issue... assuming manifest.json is not used by the client. I haven't seen my client try to access it yet. - Bryan

1 Answers

0
votes

By the way Amazon CloudFront works, you need to explicit invalidate files by providing "versions" of the same file, or just give up and use a new name. Early deletion looks costly and is billed.

Try to uploading your manifest.json from AWS Console and set a new version for the same file. It would update CloudFront endpoints without deleting the file.

Source: http://aws.amazon.com/en/cloudfront/ (Object Versioning and Cache Invalidation topic)