在高流量网站期间上传的 Smarty 模板会导致空白页面

发布于 2024-07-19 02:42:40 字数 318 浏览 2 评论 0原文

我在一个使用 Smarty 模板系统的流量非常高的网站上工作。

当我上传当前正在使用的模板的新副本时,页面会变成空白(就好像模板文件本身没有任何内容一样)。 我必须关闭lighttpd,再次上传模板,然后重新启动lighttpd。

Smarty 中是否有任何我应该使用但可能不使用的设置?

以下是我在 Smarty 内部设置的变量列表:

$smarty->use_sub_dirs = true;

$smarty->compile_check = true;

I work on a very high trafficked website that uses a Smarty templating system.

When I upload a fresh copy of a template that is currently being used, the page turns blank (as if there is nothing in the template file itself). I have to shut down lighttpd, upload the template again, and start lighttpd back up.

Are there any settings in Smarty that I should be utilizing that I might not be?

Here's a list of variables that I'm setting inside Smarty itself:

$smarty->use_sub_dirs = true;

$smarty->compile_check = true;

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

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

发布评论

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

评论(3

谜泪 2024-07-26 02:42:40

不要直接复制模板,将它们复制到某个临时文件夹中,上传完成后执行 mv (移动文件操作)

don't copy your templates directly, copy them in some temp folder and after upload finishes do a mv (move file operation)

夜雨飘雪 2024-07-26 02:42:40

您尝试清除缓存文件吗? 如果文件未完全上传并且有人请求它,则它会被缓存损坏(至少这是我的想法)。 我以前用过 smarty,也用过 lighttpd。 (决定使用 XSLT)

如果每秒请求页面超过 2 次,除非关闭 http 服务器,否则您将永远无法实际更新文件。 或者清除 smarty 缓存文件。

you try clearing the cached files? If the file is not completely uploaded and someone requests it, it gets cached broken (at least this is what i think). I used to use smarty and i too use lighttpd. (decided to go XSLT)

if the page is being requested more than 2 times a second your never going to be able to actually update the file unless your turn the http server off. Or clear the smarty cached file.

烛影斜 2024-07-26 02:42:40

您可能需要在上传文件之前打开缓存(如果已打开,请增加超时并确保缓存整个模板)。 启用缓存并将其设置为几分钟超时,以便 Smarty 不会编译新上传的模板。 访问包含您的模板的页面,以确保 Smarty 已缓存该模板。 然后,在缓存过期之前上传模板。 上传完成后,您可以再次关闭缓存(或将其设置回原始值)。

您可能需要向应用程序添加一个配置设置,以全局打开/关闭此缓存机制。

You may want to turn on caching before you upload a file (if it is already on, increase the timeout and make sure that the entire template is cached). Enable the cache and set it to a couple of minutes timeout so that Smarty does not compile newly uploaded templates. Visit the page that has your template to ensure that Smarty has cached it. Then, upload the template before the cache expires. When the upload has finished you can turn caching off again (or set it back to it's original values).

You may want to add a configuration setting to your application that can globally turn on/off this caching mechanism.

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