I wonder if it’s possible to get WebResources.axd to serve GZIP’d content when you provide a resource that is already GZipped.
Yeah I know this sounds kind of harebrained, but I’m looking for a generic solution of compacting my JavaScript resource depending on a flag and serving a pre-created GZIP’d resource. My thought was I can GZip the JavaScript file, add it as a resource to the project and then at runtime determine which resource to ship back to the client.
I realize a more common approach is to use an HTTP module to accomplish this but until this is built into ASP.NET (not counting ATLAS) I would like to avoid having to add something to an installation.
Does anybody know if it’s possible to force a WebResource to not just set the ContentType but also the Content Encoding? That appears to be the only thing that’s keeping this scheme from working.
I can do this:
[assembly: WebResource("Westwind.Web.Controls.Resources.wwScriptLibrary.gzip",
"application/x-javascript")]
And I’ve tried:
[assembly: WebResource("Westwind.Web.Controls.Resources.wwScriptLibrary.gzip",
"application/x-javascript; content-encoding: gzip")]
But unfortunately that doesn’t work.
Building a GZIP Module is not terribly difficult given that GZIPStream is part of .NET 2.0 and that you can set a Response.Filter to this stream, but it would be just fine to not have to install a module and not take the encoding hit, especially based on the fact that WebResource.axd doesn’t seem to be very aggressive about caching.
Does anybody know if it's possible to coerce WebResource.axd to serve an already GZipped resource?
Other Posts you might also like