简体   繁体   中英

ASP.Net MVC - Is it posible to gzip before putting data in cache

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM