title: Django - Loading gzip files only in production
body: <p>I am currently serving all of my static files through S3. I have a handy script that I wrote that will allow me to sync all my files up to S3. It will even gzip them before sending them along their way, changing their extensions all to .gz.</p>
  
  <p>Here's the issue. Right now, when I want to load for example, my code looks like this:</p>
  
  <pre><code>&lt;link href="{% static "sparestub/css/jasny-bootstrap.css" %}" rel="stylesheet"&gt;
  </code></pre>
  
  <p>Simple enough. On my local machine {% static %} pulls in a path to the local file system, and on my production machine, {% static %} pulls in a path to S3. But the moment I gzip all of the files in S3, changing all their extensions to .gz, {% static %} is going to return an invalid path containing the original extension.</p>
  
  <p>What is the typical solution for this type of problem?  Modify {% static %}? Is there another library that can help me out?</p>
  
  <p>EDIT:
  Or should I really just be gzipping the files and not changing the extension?</p>
  
  <p>EDIT 2: This post here (<a href="https://stackoverflow.com/questions/22196236/can-someone-walk-me-through-serving-gzipped-files-from-cloudfront-via-s3-origin">Can someone walk me through serving gzipped files from Cloudfront via S3 origin?</a>) suggests that I just gzip the files without renaming. So I did that. I can view the files in the S3 bucket using Amazon's web interface and can verify that they were successfully gzipped by looking at the HTTP header. The thing is now my app gets 403 errors whenever I try to load the files. argg.</p>