1. David Larlet
  2. django-storages
  3. Issues


Issue #159 new

Proposal - 1.2 - allow file extension mappings via AWS_HEADERS

Rich Leland
created an issue

Currently, the AWS_HEADERS setting looks like this:

    'Expires': 'Thu, 15 Apr 2010 20:00:00 GMT',
    'Cache-Control': 'max-age=86400',

There are instances where I want to attach headers for some static files differently than others. For example, I may want any static files at the path /static/myapp/.css to have a max age of 1 hour, but files at /static/admin/.css to have a max age of 1 day.

I propose allowing this mapping via AWS_HEADERS. An example could be:

    '/static/admin/(.*)\.css': {
        'Cache-Control': 'max-age=86400',
    '/static/myapp/(.*)\.css': {
        'Cache-Control': 'max-age=3600',

Comments (3)

  1. Matt Westcott

    I've just stumbled upon a particularly strong use-case for this feature at https://github.com/torchbox/wagtail/issues/633 . The current versions of Firefox and Chrome refuse to load web fonts from remote domains unless a CORS header is in place, in line with http://dev.w3.org/csswg/css-fonts/#same-origin-restriction . This means that if the static assets of your Django app include any web font files, you need to attach a header like 'Access-Control-Allow-Origin: *' to them at the point of running ./manage.py collectstatic.

  2. Log in to comment