【问题标题】:Cache buster in PHPPHP中的缓存破坏者
【发布时间】:2013-05-02 09:14:01
【问题描述】:

我正在尝试制作一个简单的 PHP 缓存破坏器,但我有一个小问题:如果我这样做
header('Location: http://localhost:8080?'.time()); 那么我的 url 将是 http://localhost:8080/?1234445,但是我需要的是像 @987654323 一样拥有它@ 不带斜杠。

请帮帮我,我是 PHP 新手。

【问题讨论】:

    标签: php url caching browser-cache


    【解决方案1】:

    http://localhost:8080/?1234445http://localhost:8080?1234445 完全一样,根据BNF for URIs。没什么好担心的。

    编辑

    You really should be using something more ...effective... for cache busting. 该帖子的亮点:

    解决缓存问题的 URL 不是可行的方法。 URL 应该代表一种访问内容的方法,仅此而已。

    [...] 带有一些有意义的标题,你会没事的。

    <?php
    header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
    ?>
    

    永无止境的重定向

    我认为正在发生并且能够在 Win7 上使用 EasyPHP 5.4.6 (PHP 5.4.6) 重现的是,负责重定向的 header 调用没有受到保护,因此重定向链如下进行:

    http://localhost:8080
    http://localhost:8080?1367490108
    http://localhost:8080?1367490108
    http://localhost:8080?1367490109
    http://localhost:8080?1367490109
    http://localhost:8080?1367490109
    http://localhost:8080?1367490110
    http://localhost:8080?1367490110
    http://localhost:8080?1367490110
    http://localhost:8080?1367490111
    http://localhost:8080?1367490111
    http://localhost:8080?1367490111
    http://localhost:8080?1367490112
    

    以此类推,永无止境的尾递归重定向[直到 Firefox 闻到老鼠的味道]。 [信息:上述重定向链的查询字符串中的时间或多或少是假设的。您的平均客户端+连接+服务器组合每秒可以重定向超过三个,并且 Firefox 在重定向循环一秒半后中止。]

    【讨论】:

    • :( 但看起来如果我使用header('Location: http://localhost:8080?'.time()); 来破坏缓存,我会得到:Firefox 检测到服务器正在以永远不会完成的方式重定向对该地址的请求。
    • 我会用我的 PHP (5.4.6) 副本做一些研究,看看能找到什么。
    猜你喜欢
    • 1970-01-01
    • 2021-12-07
    • 2020-05-19
    • 2012-03-09
    • 1970-01-01
    • 2012-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多