如何压缩响应以减少 .net 中的页面重量
谁能建议我们可以选择减少渲染 html 大小的方法 或响应减少.net中的页面重量,以便客户端可以体验更快的UI加载
我听说过JSON和GZip
,但不太了解如何使用它,甚至有更好的方法
Can anyone suggest the ways we can choose to reduce the size of the rendered html
or response to reduce page weight in .net so that the client can experience a faster loading of the UI
i've heard of JSON and GZip
but don't have much idea about how to use it or even better ways are there
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
无需编程 - GZIP 压缩输出。这是 IIS 7 中的一个模块,您(或历史者)安装该模块(一个用于静态内容,一个用于动态内容),然后在网站的配置中简单地激活该模块。
可能是最有效率的事情了。
Without programming - GZIP compression of the output. This is a module in IIS 7 that you (or the hister) installs (one for static, one for dynamic content) and that then gets simply activated in the configuration for a website.
Probably the most efficient thing.
GZip 是执行此操作的标准方法,您可以在 .NET
GZip is a standard way to do this, you can find more information about doing this in .NET here
除了已经提到过的 GZip(JSON 与此无关)之外,您还可以缩小 javascript 和 css 文件。它可能不如启用 GZIP 有效,但它仍然可以大大减小这些文件的大小,这在您有许多或大文件时特别有用。
这里有一个基于 ASP.NET MVC 的示例,但是如果你环顾四周,你也会发现一些经典 WebForms 的教程。
Aside from GZip, which has already been mentioned (JSON doesn't have anything to do with this), you can minify your javascript and css files. It might not be as effective as enabling GZIP, but it can still greatly descrease the size of these files, which is especially helpfull when you have many, or large files.
There's an example here, which is based on ASP.NET MVC, but if you look around you will find some tutorials for classic WebForms as well.