Code

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#2449 closed defect (fixed)

[patch] GZipMiddleware shouldn't gzip JavaScript

Reported by: ubernostrum Owned by: adrian
Component: Core (Other) Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Internet Explorer is known to have issues with gzipped JavaScript content, and in some testing of various AJAXy things I also found some weird issues with JSON responses being mangled only when GZipMiddleware was enabled.

So it'd probably be a good idea for the middleware to look at the outgoing Content-Type and not compress if it's JavaScript.

Attachments (2)

gzip.diff (532 bytes) - added by ubernostrum 8 years ago.
Patch to make GZipMiddleware smarter about JavaScript
gzip.2.diff (533 bytes) - added by ubernostrum 8 years ago.
Better patch using Simon's suggestion

Download all attachments as: .zip

Change History (7)

Changed 8 years ago by ubernostrum

Patch to make GZipMiddleware smarter about JavaScript

comment:1 Changed 8 years ago by ubernostrum

  • Summary changed from GZipMiddleware shouldn't gzip JavaScript to [patch] GZipMiddleware shouldn't gzip JavaScript

comment:2 Changed 8 years ago by Simon Willison

It looks like this patch won't handle the case where the Content-Type header includes a charset:

Content-Type: text/javascript; charset=utf-8

There are routines in the Python email package that can handle parsing this kind of information out of a header, although to be honest the following would probably work fine:

'javascript' in response.headers['Content-Type']

comment:3 Changed 8 years ago by ubernostrum

Ack. Yeah.

Shouldn't submit patches at 4AM...

Changed 8 years ago by ubernostrum

Better patch using Simon's suggestion

comment:4 Changed 8 years ago by jacob

  • Resolution set to fixed
  • Status changed from new to closed

(In [3503]) Fixed #2449 -- gzip middleware no longer gzips Javascript. Thanks for the prob, ubernostrum

comment:5 Changed 8 years ago by jacob

Thanks for the *prod*, that is.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.