-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
django compressor: is it doing anything? besides 500 crashing Django? #397
Comments
This error raises its head again after changing an environment variable in |
Additionally, by default, Again based on casual perusal of the production source, it doesn't look like there are obviously compressible assets that we're missing at the moment. |
Following up after reading more carefully: we might be using it in "offline mode" in prod, in which case the management command needs to be run. I'm not sure which key it's missing -- could be something for managing its connection to AWS or to another cache server (redis?) somewhere. |
@yourcelf I'm surprised you didn't bump into this issue, because you're also using a beta system database dump and the same branch of git code. Very confusing. The Now I bet that's the problem. I probably need to fix the memcache problem so that online mode works and the system doesn't need to fall back to offline mode. I bet that's the difference in our configurations. |
I have memcache running on my system, and you probably didn't on your VM? Could explain my lack of issues. |
Yeah I thought I installed it, but maybe I only installed |
I only installed
I have run |
I disabled offline compression in In any case, this does not effect the production systems and I appear to have found a workaround for my use for the time being. Good enough for closing this ticket. |
ehh turns out django-compress could potentially be very useful for dealing with CDN problems in #396. At present, I do not see anything happening with compress. All the js and css appear to be posted in the S3 bucket as-is, even though So ... the question is reiterated: does it do anything? And can we make it, because that would mesh well with our CDN. |
This configuration appears good: The default storage env var is confirmed to be S3 boto on staging and my VM. The cloudfront domain on both is also correct from the environment. |
found it! compress is pushing into the bucket under Django has been instructed to prepend karmaworld/karmaworld/settings/prod.py Lines 111 to 114 in 3fb9188
It looks like these files are working correctly with compress: karmaworld/karmaworld/templates/base.html Lines 11 to 28 in 3fb9188
As taken from http://karmanotes-beta.herokuapp.com/ <link rel="shortcut icon" href="//d2ry5v6uki5dz0.cloudfront.net/static/img/favicon.ico">
<link rel="stylesheet" href="https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/css/9de46941e995.css" type="text/css" media="all" />
<script type="text/javascript" src="https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/js/a52a868564de.js"></script>
<!-- block pagestyle -->
<link rel="stylesheet" href="https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/css/ac272f84448a.css" type="text/css" media="all" />
<!-- end block pagestyle --> |
So that answers the question of "Does it integrate with collectstatic so that compressed static files are actually uploaded?". Yeah, actually it does. It appears that "Does it integrate with collectstatic so that uncompressed static files are not actually uploaded?" is not possible. All static files are uploaded whether or not they are handled by compress. So Here's where karmaworld/karmaworld/templates/notes/note_base.html Lines 31 to 37 in 3fb9188
I disabled beta's cloudfront for testing. I see attempts to download the hash file names, and no attempts to download e.g. Waiting for beta's cloudfront to come back online to test again. |
okay, cloudfront is running again, and once again I am seeing Is FireFox translating the hash codes into files even in the debug areas? |
answer: no. At the top of the source I'm looking at is still calling CACHE hash filenames from |
Blah this is inconsistent and annoying. The topmost |
Also jQuery seems to be missing. |
jQuery should be compressed after the footer. karmaworld/karmaworld/templates/base.html Lines 45 to 71 in 3fb9188
In the page source I'm looking at: <!-- end include footer-->
<script type="text/javascript" src="https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/js/b96ad19ec98b.js"></script>
<script type="text/javascript" src="//use.typekit.net/pnc8diw.js"></script>
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
<script>
$(function() {
$(document).foundation();
});
</script>
<!-- block pagescripts --> It looks like jQuery is crammed in there, but either it is not loaded at the right time or it is not in the correct namespace. I assume this is a problem with compress. |
These problems do not appear on http://karmanotes-beta.herokuapp.com/note/harvard/cs-50-114/1st-lecture. It appears that jquery is crammed in the same place and even using the same cloudfront hash; that did not get updated. So it looks like missing jquery is a separate issue entirely from compress. <!-- end include footer-->
<script type="text/javascript" src="https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/js/b96ad19ec98b.js"></script>
<script type="text/javascript" src="//use.typekit.net/pnc8diw.js"></script>
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
<script>
$(function() {
$(document).foundation();
});
</script>
<!-- block pagescripts --> |
forked jquery issue to #400 as it now appears unrelated to compress. |
ah, some of the weirdness with compress might be due to It seems like the front end never uses manifest.json, and the backend can get around caching by accessing the S3 bucket directly using the default storage. |
darnit. S3 and Cloudfront appear to match for http://karma-beta.s3.amazonaws.com/static/CACHE/manifest.json {
"442c18c2a05bb4d3fd13ee627a5c7417": "<link rel=\"stylesheet\" href=\"https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/css/febe1bc0c6e9.css\" type=\"text/css\" media=\"all\" />",
"8814067983406d53beedaae5667ace44": "<script type=\"text/javascript\" src=\"https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/js/9baa4331d306.js\"></script>",
"97b36458b6db8b3e32dc5a8723c35913": "<link rel=\"stylesheet\" href=\"https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/css/cc9da0afb61c.css\" type=\"text/css\" media=\"all\" />",
"a7faab5496fe386820911dbc1b2d1d16": "<script type=\"text/javascript\" src=\"https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/js/a52a868564de.js\"></script>",
"bcb3f4d38cd2f812acfa34b2b280c967": "<script type=\"text/javascript\" src=\"https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/js/b96ad19ec98b.js\"></script>",
"82d94a4224b72da20caf3a1be3a6d54d": "<link rel=\"stylesheet\" href=\"https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/css/ac272f84448a.css\" type=\"text/css\" media=\"all\" />",
"efdec72c75dd83fb57fc636dc8cd4040": "<script type=\"text/javascript\" src=\"https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/js/1c9098619b8b.js\"></script>",
"86d6e666af9057070c90cfd1c6827b4b": "<link rel=\"stylesheet\" href=\"https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/css/c65cf523ca3b.css\" type=\"text/css\" media=\"all\" />",
"d4b49aaae233b114a3a190733be902b5": "<script type=\"text/javascript\" src=\"https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/js/a0cebb0c3c74.js\"></script>",
"0b7b58e7f7597cee10588304e025d150": "<link rel=\"stylesheet\" href=\"https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/css/7c08411ba945.css\" type=\"text/css\" media=\"all\" />",
"88e86e7fea3c44b253cf997fad40758d": "<link rel=\"stylesheet\" href=\"https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/css/db6299073c6f.css\" type=\"text/css\" media=\"all\" />",
"d71b198ed04ac08b1724ed508ff86911": "<script type=\"text/javascript\" src=\"https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/js/fc79bd7d88e1.js\"></script>"
} https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/manifest.json {
"442c18c2a05bb4d3fd13ee627a5c7417": "<link rel=\"stylesheet\" href=\"https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/css/febe1bc0c6e9.css\" type=\"text/css\" media=\"all\" />",
"8814067983406d53beedaae5667ace44": "<script type=\"text/javascript\" src=\"https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/js/9baa4331d306.js\"></script>",
"97b36458b6db8b3e32dc5a8723c35913": "<link rel=\"stylesheet\" href=\"https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/css/cc9da0afb61c.css\" type=\"text/css\" media=\"all\" />",
"a7faab5496fe386820911dbc1b2d1d16": "<script type=\"text/javascript\" src=\"https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/js/a52a868564de.js\"></script>",
"bcb3f4d38cd2f812acfa34b2b280c967": "<script type=\"text/javascript\" src=\"https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/js/b96ad19ec98b.js\"></script>",
"82d94a4224b72da20caf3a1be3a6d54d": "<link rel=\"stylesheet\" href=\"https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/css/ac272f84448a.css\" type=\"text/css\" media=\"all\" />",
"efdec72c75dd83fb57fc636dc8cd4040": "<script type=\"text/javascript\" src=\"https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/js/1c9098619b8b.js\"></script>",
"86d6e666af9057070c90cfd1c6827b4b": "<link rel=\"stylesheet\" href=\"https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/css/c65cf523ca3b.css\" type=\"text/css\" media=\"all\" />",
"d4b49aaae233b114a3a190733be902b5": "<script type=\"text/javascript\" src=\"https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/js/a0cebb0c3c74.js\"></script>",
"0b7b58e7f7597cee10588304e025d150": "<link rel=\"stylesheet\" href=\"https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/css/7c08411ba945.css\" type=\"text/css\" media=\"all\" />",
"88e86e7fea3c44b253cf997fad40758d": "<link rel=\"stylesheet\" href=\"https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/css/db6299073c6f.css\" type=\"text/css\" media=\"all\" />",
"d71b198ed04ac08b1724ed508ff86911": "<script type=\"text/javascript\" src=\"https://d2ry5v6uki5dz0.cloudfront.net/static/CACHE/js/fc79bd7d88e1.js\"></script>"
} |
I just noticed the key changed. Earlier I pasted this:
now I'm getting this:
It looks like I'll need to run |
nope, didn't help. Alright, so the key has changed, but running |
PS after all the compress running and such, I just tested that link from my local server. Still 500 with the error: Looking at the manifest above, it certainly is missing. I'm not sure how many times I need to run |
Just to confirm I'm cleanly in the branch:
|
the key the error references is not in the manifest.json I generated locally. FWIW, I run django-compressor in 'online' mode for all of my production sites. The only time the performance is any different is when generating files for the first time with an empty cache. Did you figure out the train you were following earlier of checking whether the contents of |
The I can confirm that I am pushing code up to S3 because it is hosting the new .js files and I see current timestamps. e.g. Here's the S3 version (10 minutes old): Here's the CloudFront version: |
I wonder if I can inject a printout to determine what is the context that is generating this missing key. |
My best guess: when executing This would explain both the missing key errors and the fun error that I got above. My error shows up if |
Well I output the context, but man, that's a lot of noise and very little signal. I think I might pdb this and step through what it's doing to the context to figure out what is actually being hashed. |
Switching the wysiwyg to reference the non-minified version of its source file eliminates my |
pdb had no output :( I was hoping to dive into this interactively to determine just what is missing. |
this is the chunk that is being choked on:
wysiwyg is definitely in there, and it's the only thing "new" to this code base in general. It sounds like you found the problem, although I wish I understood why. |
Though it's not really fixed. Commenting out the wysihtml5 js doesn't fix the problem when running with I think the |
(ps I upgraded django-compressor locally to 1.4; but no improvement) |
turning in for the night. Good luck. This one's not cracking easily. |
@yourcelf good night, thanks for your help. I would have fumbled around with the wrong project, so you saved me going down the wrong path. |
There is this: django-compressor/django-compressor#443 |
Given the chunk of three CSS files that are causing the missing key error, I noticed that they are all referencing cloudfront. I figured I'd see what's actually there. http://d2ry5v6uki5dz0.cloudfront.net/static/wysihtml5/toolbar.css is a blank file. The other two have file contents. |
I don't know if it is supposed to be empty, but I'm going to remove it from the This is apparently where the empty file is coming from: |
woo! moved past that error. new one.
|
not a single empty file in that collection. |
All three wysihtml5 includes are coming from I'll comment that out just to see if I can avoid a 500 error with compress. |
Try commenting the CSS out too; it's also handled by compress. |
you mean this? I commented that out back in this comment: #397 (comment) |
yup, that one. :) |
Alright commenting out both media includes allows the page to load without a 500 error from compress. Perhaps we should move those media includes outside of compress so that they are available. The CSS file was empty, so I could understand why that might cause an issue. The three JS files look alright to me although I didn't look closely. |
Alright I pulled those media tags out of the compress tags. They are being included in the source (albeit directly from static and not inside a compress hash file) and the server isn't throwing a 500. Visiting
I think this is one of the examples @yourcelf had showed me interactively, but with the error, I don't see anything where the note should be. Unsure if that is due to the changes made with how compress works (and thus should stay in this ticket) or if it is worthy of its own ticket. |
While running a local VM, I got an error about some compress key missing and that I needed to run
manage.py compress
. This is a new issue, but it looks like compress has been around for some time.The error might have been because I was running a database dumped from the beta system, but that assumes
compress
uses the database to store stateful information.It sounds like compress is used to glob together js and css files in a tight format. That's great! But I've never run it manually before.
collectstatic
so that compressed static files are actually uploaded? [Yes]collectstatic
so that uncompressed static files are not actually uploaded? [No, all files are uploaded regardless of compress]The text was updated successfully, but these errors were encountered: