du8864 2010-07-21 10:23
浏览 26
已采纳

网站崩溃(PHP致命错误),而html编码器保存智能模板

We're running rather big website (~400K page views daily) and using Smarty as templates engine. HTML coder changes templates every day and every template change (almost every) causes website crash because of PHP Fatal error: Call to undefined function _smarty_tplfunc_f0cb5c08ca1726d224308f2f6bd56b4f_0() in ... PS: Yes, we're using $smarty->compile_check to see template changes immediately.

To fix this error, we're cleaning all website cache. I don't feel comfortable with it!

Who know, how can I fix it? And why this error occures every time (almost every time) when template is changed.

Thank you.

  • 写回答

1条回答 默认 最新

  • doucan4873 2010-07-22 01:03
    关注

    The best way to avoid this kind of issue is to upload to a temporary file, then rename it. That way there's no chance for a partial file appearing.

    As for why it happens every time, think about it. 400k page views per day == 4.6 requests per second average. Considering most sites I've ever seen have far more traffic over specific hours (during the day), I'd suspect that you're seeing upwards of 10 to 20 requests per second. at that rate, if the file write (because of the upload) takes longer than 0.05 seconds, the chance of a read while it's being written to rises sharply.

    So your choices (In order of most robust to least. You can always do multiple):

    1. Do the uploads after hours when traffic is (hopefully) lower...
    2. Use a FTP server that does the renaming bit for you.
    3. Manually rename the file when you upload the new one. (Important; Rename to overwrite the original. don't delete or move the original first)...
    4. Hack Smarty to ignore the new files with a timestamp less than about 10 to 30 seconds old (Simply call filemtime() to determine when it was last modified. Be sure to call clearstatcache() first so you don't get an old time)...
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化