静音抑制_抑制空白
靜音抑制
…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/
靜音抑制
總結
- 上一篇: 1.4 自定义框架
- 下一篇: jeecg框架MybatisPlus出现