简体   繁体   English

ASP.Net MVC-将数据放入缓存之前是否可以gzip

[英]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. 只是想知道是否有人在将数据放入缓存之前是否知道是否可以gzip生成结果...请注意,我想使用我拥有的CompressAttribute和内置的OutputCacheAttribute。 I'm pretty sure its possible, because I have heard Jeff A. talking about it on a couple of podcasts... 我非常确定这是可能的,因为我在几个播客上都听过Jeff A.谈论它。

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... 我知道我可以改变属性的处理顺序,但是除了在标题中放入gzip并将过滤器设置为GZipStream之外,这似乎什么也没做。我不确定何时使用此方法,何时实际压缩发生...

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... 我首先要压缩的原因很简单,因为我只想在服务器上gzip一次,然后缓存结果...因此节省了CPU周期...

Cheers Anthony 干杯安东尼

Yes it is. 是的。 In fact... I'm pretty sure stackoverflow does it. 实际上...我很确定stackoverflow会做到这一点。

Check out this blog post from Scott Hanselman - Zip Compressing ASP.NET Session and Cache State 查阅Scott Hanselman的这篇博客文章-Zip Compressing ASP.NET Session and Cache State

HTHs, HTHS,
Charles 查尔斯

On IIS7 you can use integrated compression instead of 3rd parties solutions. 在IIS7上,可以使用集成压缩代替第三方解决方案。 Configuration sample is here . 配置样本在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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