ThePiepers.net serves the compressed JS and CSS files using the nginx memcached module. The python backend compresses the content and stores the content in memcached to be served via nginx.
This weekend, I upgraded to Django 1.3. After some testing, the JS and CSS files were bypassing memcached and being served by python. As you can imagine, this is not the most efficient method to serve static content.
I restarted nginx in debug mode and the log said the key was not found:
2011/07/02 22:00:59 [info] 3486#0: *576 key: "staticcomp_common_146b3bfb21d40db942309668eda" was not found by memcached while reading response header from upstream, client.
This was odd because when I queried it directly via the Django memcached backend, the data was present.
It used to work, so I figured that the memcached log might reveal more of what was going on. I restarted it in debug mode. The memcached log had two different keys in it:
28: Client using the ascii protocol
<28 get staticcomp_common_146b3bfb21d40db942309668eda
>28 END
<28 connection closed.
28: Client using the ascii protocol
<28 get :1:staticcomp_common_146b3bfb21d40db942309668eda
>28 END
<28 connection closed.
Nginx was requesting the key as configured, but Django was using a different key format even though I didn’t specify a version. The new Django 1.3 cache framework key format has a prefix and version prefix.
To fix the issue, place the prefix and version format (":1:" where 1 is the default version number) into the nginx configuration:
location ... {
...
set $memcached_key :1:staticcomp_$1_$3;
}
The Django key will still be staticcomp_common_146b3bfb21d40db942309668eda.

