shell实现定期清理网站缓存数据

    Read

如果第一个脚本不行,可以尝试第二个脚本方案!

网站采用了一些方法进行加速(redis\cdn),这样就降低用户访问后端MySQL的压力、以及前端速度不太好的问题,对用户请求到的所有页面进行了缓存,既然数据缓存了,解决用户看到的页面是否为最新页面就提上日程,下面这个脚本就诞生了。SourceByrd's Weblog-https://note.t4x.org/code/fresh-web-cache/


将脚本加入定时任务,由于网站不定期更新,更新不频繁,因此每天执行任务即可。
SourceByrd's Weblog-https://note.t4x.org/code/fresh-web-cache/

另外一个思路:SourceByrd's Weblog-https://note.t4x.org/code/fresh-web-cache/

1:redis的主要目的是为了缓存数据;
2:把redis缓存数据清空,然后重新启动redis即可完成;
3:因为个人网站一般凌晨4:00左右访问量最低,且更新周期不快;SourceByrd's Weblog-https://note.t4x.org/code/fresh-web-cache/

这个脚本一样的功效,效果不如上面的脚本,上面的额脚本缺点是没有做文章的判断。SourceByrd's Weblog-https://note.t4x.org/code/fresh-web-cache/

SourceByrd's Weblog-https://note.t4x.org/code/fresh-web-cache/

然后定时任务,每周或者每天执行一次即可!SourceByrd's Weblog-https://note.t4x.org/code/fresh-web-cache/ SourceByrd's Weblog-https://note.t4x.org/code/fresh-web-cache/

申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!
Byrd
  • by Published on May 17, 2016
  • 原文链接:https://note.t4x.org/code/fresh-web-cache/
Comments  5  Guest  5
    • random
      幽烛 0

      内容专业,速度够快

      • random
        张戈 0

        其实redis使用?c=y就能刷新全部缓存:
        缓存问题
        index-with-redis.php中有注释
        Appending a ?c=y to a url deletes the entire cache of the domain, only works when you are logged in
        Appending a ?r=y to a url deletes the cache of that url
        Submitting a comment deletes the cache of that page
        Refreshing (f5) a page deletes the cache of that page
        登录后台网站url后面加上?c=y即可刷新整个网站
        可以在网站页面后面加上?r=y即可手工刷新
        提交评论会自动刷新页面
        刷新(f5)页面也可以刷新页面

          • Byrd
            Byrd

            @ 张戈 其实还是有问题,前提是登陆后刷新、或者有人评论、又或者F5刷新,大概三个方式。都必须人为操作,我最原始想法是模拟F5来进行,脚本不好操作,就想redis方面来想办法。其实两个脚本都没有很好的实现我想要的效果。

          • random
            斯托克笔记 0

            哇哦,好专业的博客。

          匿名

          Comment

          Anonymous

          :?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: