Django

Code

Ticket #2449 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

[patch] GZipMiddleware shouldn't gzip JavaScript

Reported by: ubernostrum Assigned to: adrian
Milestone: Component: Core framework
Version: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

gzip.diff (0.5 kB) - added by ubernostrum on 07/30/06 02:44:26.
Patch to make GZipMiddleware smarter about JavaScript?
gzip.2.diff (0.5 kB) - added by ubernostrum on 07/31/06 11:29:04.
Better patch using Simon's suggestion

Change History

07/30/06 02:44:26 changed by ubernostrum

  • attachment gzip.diff added.

Patch to make GZipMiddleware smarter about JavaScript?

07/30/06 02:44:46 changed by ubernostrum

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

07/30/06 09:18:40 changed 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']

07/30/06 16:06:12 changed by ubernostrum

Ack. Yeah.

Shouldn't submit patches at 4AM...

07/31/06 11:29:04 changed by ubernostrum

  • attachment gzip.2.diff added.

Better patch using Simon's suggestion

07/31/06 16:31:36 changed by jacob

  • status changed from new to closed.
  • resolution set to fixed.

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

07/31/06 16:31:55 changed by jacob

Thanks for the *prod*, that is.


Add/Change #2449 ([patch] GZipMiddleware shouldn't gzip JavaScript)




Change Properties
Action