在代码中压缩 ASPX 页面视图或在 IIS 中压缩 HTTP?
过去,对于具有大视图状态的页面,我重写了 PageStatePersister 类,因此在保存状态时我会对其进行压缩。在加载时我将其解压缩。我还没有真正考虑过这个问题,但是 IIS 可以更好地处理这样的事情吗?我这样做的原因是为了让我的页面更精简,因为页面上有很多自定义控件并且视图状态很大。这是我获取原始代码的地方:
http://www.codeproject .com/KB/viewstate/ViewStateCompression.aspx?msg=1906999
In the past, with pages with large viewstate I have overridden the PageStatePersister class so when the state is saved I compress it. On Load I decompress it. I have haven't really thought about it, but could IIS handle something like this better? The reason I did this was to keep my pages slimmer because I have a lot of custom controls on the page and the viewstate was huge. This is where I got my original code from:
http://www.codeproject.com/KB/viewstate/ViewStateCompression.aspx?msg=1906999
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们在 IIS 级别进行压缩,它使事情变得更干净、更简单。然而,我们只是一个具有一种用途的网站,当您转移到多个网站以及您可能不想压缩内容的类似网站时,事情就会开始变得混乱。
我认为 IIS7 的情况有所改善,您可以进行按站点压缩。
您还可以将所有内容作为一个整体进行压缩,而不仅仅是页面的一部分,这可能意味着整体压缩率更高。
We compress at the IIS level, it makes things cleaner and simpler. However we're just one website with one use, things start to get messed as you move to multiple websites and the like with which you might not want to compress content.
I think the situation improved with IIS7 though and you can do per-site compression.
You also have the benefit of compressing everything as a whole rather than just one part of the page which may mean a better compression ratio overall.