静音抑制

tech2024-05-06  80

静音抑制

…posted by davidjmedlock:

…由 davidjmedlock 发布 :

Over the weekend I happened to be working on a project with another developer and he emailed me about an issue with a custom tag that he was using. He said that there was an inordinate amount of white space in his documents. In fact, the document with all the white space in it was about 40KB as opposed to the document without white space being around 16KB. Yikes!

上周末,我碰巧正在与另一位开发人员一起开发项目,他通过电子邮件向我发送了有关他正在使用的自定义标签的问题。 他说他的文件中有太多空白。 实际上,包含所有空白的文档大约为40KB,而没有空白的文档大约为16KB。 kes!

The reason for this is because in the execution of the page, the server must translate the CFML into p-code, which is executable by the application server. In the conversion, the CFML becomes whitespace.

其原因是因为在执行页面时,服务器必须将CFML转换为p代码,该p代码可由应用程序服务器执行。 在转换中,CFML变为空白。

When you have ColdFusion code in a display document and then view the source, you’ll see that everywhere the ColdFusion code was is now white space. This can cause your documents to be bloated and it can eat up your bandwidth quickly.

当您在显示文档中包含ColdFusion代码,然后查看源代码时,您会看到ColdFusion代码到处都是空白。 这会导致您的文档过大,并且会很快耗尽您的带宽。

The best way that I’ve discovered for suppressing whitespace is to go into ColdFusion Administrator, go to the Settings page and click “Enable Whitespace Suppression”. This will drastically reduce the size of your pages, especially if you are doing anything database intensive where you have large queries. It will also make your code more readable.

我发现抑制空白的最好方法是进入ColdFusion Administrator,转到“设置”页面,然后单击“启用空白抑制”。 这将大大减少页面的大小,尤其是当您在需要大量查询的情况下执行数据库密集型操作时。 它还将使您的代码更具可读性。

I know that there are ways to do this in code, using cfprocessingdirective, cfsetting, and cfsilent, but with the ability to set it up in the server itself, I really don’t see any reason to have to do it in code. Even if you’re on a shared host, you should email them and ask them to make this small change for you. It will decrease the bandwidth used and they should be able to do it for you without a problem. (If they ask you what the ColdFusion Administrator is, then find another host!)

我知道可以使用cfprocessingdirective,cfsetting和cfsilent在代码中执行此操作,但是由于能够在服务器本身中进行设置,因此我真的没有理由在代码中执行此操作。 即使您在共享主机上,也应该向他们发送电子邮件,并请他们为您进行此小更改。 它将减少所使用的带宽,他们应该可以为您轻松解决问题。 (如果他们问您ColdFusion管理员是什么,请找到另一个主机!)

There’s more information about displaying output in the Programming ColdFusion book by OReilly. Chapter 11 is where you’ll want to look.

在OReilly的《 Programming ColdFusion》一书中,有更多有关显示输出的信息。 第11章是您想要看的地方。

As a side note, I looked around a little bit to find out if enabling the suppression of whitespace has any noticeable effect on server performance and I haven’t seen anything in there about it. I could see how it might slow it down ever so slightly, since it now has to clean up after itself, but it also seems that it may speed up just a very little bit since it is dealing with less data in terms of memory… If anyone has references on the matter, I’d be interested to see them.

附带说明一下,我环顾了一下,以了解是否启用抑制空格对服务器性能是否有任何显着影响,但我没有发现任何相关信息。 我可以看到它可能会如此缓慢地降低它的速度,因为它现在必须自行清理,但由于它处理的内存数据较少,因此它似乎也可能会加速一点点……任何人都对此事有参考,我很想看到他们。

翻译自: https://www.sitepoint.com/suppressing-white-space/

静音抑制

最新回复(0)