views:

322

answers:

2

Hi guys

Just wondering if anyone knows whether its possible to gzip results before putting the data in the cache...Note I am wanting to use a CompressAttribute I have and the built-in OutputCacheAttribute. I'm pretty sure its possible, because I have heard Jeff A. talking about it on a couple of podcasts...

I know I can sort of change the order in which the attributes are processed but this seems to do nothing besides put gzip in the header and set the filter to a GZipStream... I'm not sure when using this method, when the actual compression occurs...

The reason I want to compress first is fairly simple, as I only want to gzip on the server once and then cache the results... hence saving CPU cycles...

Cheers Anthony

+2  A: 

Yes it is. In fact... I'm pretty sure stackoverflow does it.

Check out this blog post from Scott Hanselman - Zip Compressing ASP.NET Session and Cache State

HTHs,
Charles

Charlino
A: 

On IIS7 you can use integrated compression instead of 3rd parties solutions. Configuration sample is here.

vasek7