Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 971589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:59:17+00:00 2026-05-16T02:59:17+00:00

I am using the Django GZip middleware (django.middleware.gzip.GZipMiddleware) to compress content if the browser

  • 0

I am using the Django GZip middleware (django.middleware.gzip.GZipMiddleware) to compress content if the browser allows compression.

If the browser is Internet Explorer (MSIE) and the content is a Javascript file, then the middleware does not gzip the content. My understanding is that the middleware avoids compressing in this case because IE6 (without patches) has issues with gzipped responses.

For our site, we do not support IE6, but we do support IE7 and IE8. Considering that we do not support IE6, would it be best practice for us to gzip all javascript files even if the browser is IE?

If so, what is the best approach for getting these files gzipped? We would like to continue to use a Django middleware module for gzip. Should we make a copy of the gzip middleware module and edit the few lines that deal with IE and Javascript (this feels like we would be violating DRY)? Using Apache for gzip is also an option.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T02:59:18+00:00Added an answer on May 16, 2026 at 2:59 am

    Versions of IE6 that are affected by problems with gzip on JS/CSS are no longer in common circulation (and were a minority case even at the time). And Netscape 4 is long, long gone.

    For this reason I would strongly recommend removing all extant User-Agent-sniffing gzip hacks. Send compressed HTML/JS/CSS to all browsers that request it (with Accept-Encoding), as per standard HTTP/1.1.

    if "msie" in request.META.get('HTTP_USER_AGENT', '').lower():
    

    Oh dear. That’s a really poor test even by UA-sniffing’s dismal standards. No checking that it’s actually MSIE in the right place in the string (as opposed to anywhere in all the trailing bits; easy to get false positives), and it doesn’t check for SV1 which was traditional for the gzip test (as IE6SP2+ versions cannot be affected by the bug), so it breaks compression for all IE which is just unnecessary.

    It also doesn’t set Vary: User-Agent, so proxies will cache the wrong version. And it sets Vary: Accept-Encoding for IE when not using Content-Encoding, so it’ll break cacheing in IE.

    Should we make a copy of the gzip middleware module and edit the few lines that deal with IE and Javascript (this feels like we would be violating DRY)?

    You could, and maybe submit the patch to Django. Because their current approach is IMO simply broken.

    Using Apache for gzip is also an option.

    Yes, if you’ve got Apache upstream definitely use that (eg. with mod_deflate). It’s most efficient if you can use it to serve static files like scripts too. (Try to keep your JS in static scripts rather than generating/templating on-the-fly.)

    Again, don’t use the browser-sniffing rules mentioned on the mod_deflate page. They’re fragile and ugly, and are trying to code around a Netscape problem that has affected no-one in the last decade.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Firstly, I'm using Django. Django provides gzip middleware which works just fine. Nginx also
I'm considering using Django for a project I'm starting (fyi, a browser-based game) and
I'm using django-taggit , which handles the attachment of tags to arbitrary content types.
Using Django's built in models, how would one create a triple-join between three models.
I'm using Django to write a blog app, and I'm trying to implement a
I am having problems using django-tagging . I try to follow the documentation but
I'm using Django and Python 2.6, and I want to grow my application using
I'm using django and when users go to www.website.com/ I want to point them
I am currently using Django to construct JSON encoded objects which a retrieved using
Is it possible to have a variable number of fields using django forms? The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.