如何从服务器响应中删除空格和换行符?

发布于 2024-08-30 11:50:48 字数 137 浏览 1 评论 0原文

当我使用浏览器/AJAX 请求请求页面时,我看到很多空格和换行符,我认为这一定会增加一些检索响应的开销,因为它们也属于字符意味着字节和大小。正确的 ?

有什么方法可以在从服务器发送时将其删除吗?如何 ? (我使用IIS和asp.net进行开发)

When i request a page using browser / AJAX request i see lot of spaces and newlines which i think must be adding some overhead for retrieving the response as they too belong to characters means bytes and size. right ?

Is there some way it can be removed while sending from the server ? how ?
(I am using IIS and asp.net for development)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

命比纸薄 2024-09-06 11:50:48

有一些 http 模块可以满足您的要求,

例如这里是一个
http://madskristensen.net/post/ A-whitespace-removal-HTTP-module-for-ASPNET-20.aspx

但在我看来,在某些情况中,您不需要这样做,因为您花费了更多时间在服务器上清除页面,而不是发送它,特别是如果它是 gZipped 的。一个好的解决方案是手动缓存最终的透明页面,然后发送缓存的内容(在需要时更新它等),但这是更多的代码。

还有类似问题
asp.net MVC ActionFilter 用于删除结果中的空行< /a>

asp.net MVC ActionFilter 用于删除空行结果

缩小 ASP.NET 应用程序的 Html 输出

谷歌搜索的关键是“Minify Html

There are some http modules that make all ready what you ask

For example here is one
http://madskristensen.net/post/A-whitespace-removal-HTTP-module-for-ASPNET-20.aspx

How ever in some cases in my opinion is that you do not need to do that because you spend more time on server clearing the page, than send it, especial if it is gZipped. One good solution is to manual cache the final clear page, and then send the cached (update it when its needed etc), but this is a lot more code.

Also similar questions
asp.net MVC ActionFilter for remove empty lines in result

asp.net MVC ActionFilter for remove empty lines in result

Minify Html output of ASP.NET Application

And the keys to search on google is "Minify Html"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文