douwa1304 2012-11-05 23:12
浏览 117
已采纳

如何清除缓存,在给定时间内重新加载当前页面?

how to clear the cache and auto reload page in a given time in yii framework ? like e.g in the next 5 hours, the content of the page should change prior to clear cache then reload the page

$time = date('h:i:s A', strtotime("+5 hours"));

and then in the next 5 hours, it will clear cache again and reload the same page and show new content

  • 写回答

1条回答 默认 最新

  • duanhao5038 2012-11-06 00:33
    关注

    If i understand well the question.

    In the Yii view that your are, add something like this in javascript

    <script>
     setTimeout(function(){ window.location = "<URL>";}, 5*60*1000);
    </script>
    

    this is a redirect after 5 minutes. if you want 5 hours just use

    300*60*1000
    

    and point the URL to www.example.com/controller/action you want.

    If still you wanna do it in php i believe you can add this line to your view.

    <?php header("Refresh: 18000; URL=http://www.example.com/controller/action"); ?>
    

    here 18000 is in seconds.

    Hope it helps.

    but if you are only updating small bits of the view.. why not create a timer to make ajax request to the controller/action you want to update the data from? Yii is ready for that kind of need.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!