1

是否有任何解决方案或替代 ColdFusion 标记来包含静态文本文件而不在 /WEB-INF/cfclasses 下创建模板缓存?

问题是我的动态页面随着时间的推移而增长。每个页面都需要包含一个静态文件。

例如

<cfinclude template="mapping/static_1.txt> for page 1
<cfinclude template="mapping/static_2.txt> for page 2
<cfinclude template="mapping/static_3.txt> for page 3
....etc.

由于页面数量增长到 2000 页,导致服务器停机,因为系统生成了超过服务器限制的 2000 个缓存模板。

我可以要求托管支持来扩展限制,但这不会是随着时间的推移而增长的动态页面的长期解决方案。

显然,不需要计算,因为要包含的文件是包含静态 HTML 标记(不涉及脚本)的静态文本 (.txt)。

除此之外,是否有任何替代标签<cfinclude >仅显示文件内容而无需二进制计算和缓存创建?

或者有什么解决方案可以防止服务器缓存 .txt 文件?

对不起,这个问题可能很简单,但我是 CF 的新手。您的指针将不胜感激。

干杯查农


我的托管支持不建议一起禁用缓存。

无论如何,我想出了一个简单的解决方案,使用<cffile>而不是<cfinclude>.

使用<cffile>服务器时不会执行每一行并创建缓存。相反,它只是抓取整个文件并将其放入变量中。

4

2 回答 2

5

如果这些是静态 HTML 文件,为什么要使用 CFINCLUDE?例如,使用 FileRead()(或使用 FileOpen/FileReadLine/FileIsEOF 的更长版本) - 甚至使用 action="read" 的 CFFILE。

<cfset variables.content = FileRead("mapping/static_1.txt")>
<cfoutput>
    #variables.content#
</cfoutput>

如果没有要处理的 CFML/CFScript,那么使用 CFINCLUDE 是没有意义的。

于 2012-08-29T06:58:32.147 回答
3

You don't need to cache any compiled class files at all: there's a setting in CFAdmin to switch this caching off (on the Cache page: "Save Class Files"). Those cached files are only really a benefit at server start-up time: it saves files being re-compiled when they're first accessed. This overhead is neglible, really. It used to be considerable back in the days of CFMX6 & 7, but not so much since then.

There is - as far as I know - no way to pick & choose which files have their compiled classes saved. It's all or nothing.

What one could do, I suppose, is to switch the setting on, compile all the apps "main" files so their classes are saved, then switch the setting off. One would need to repeat this process whenever one adds new files to the application though. Still: that's not such a hardship.

But I see no benefit in having these files saved at all, these days.

于 2012-08-29T06:11:45.857 回答