我所做的新更改不会显示在实际网站上(可能是缓存)

时间:2017-02-02 16:41:36

标签: javascript php html .htaccess caching

网站从昨天起就开始了,当我在托管服务器上传网站时,我为ExpiresByType目的创建了.htaccess文件,结果证明这是一个错误,因为我猜这就是为什么改变没有出现在现场。这是我的.htaccess文件:

<IfModule mod_expires.c>
    ExpiresActive on
    ExpiresDefault                                      "access plus 1 month"

  # CSS
    ExpiresByType text/css                              "access plus 1 year"

  # Data interchange
    ExpiresByType application/json                      "access plus 0 seconds"
    ExpiresByType application/ld json                   "access plus 0 seconds"
    ExpiresByType application/xml                       "access plus 0 seconds"
    ExpiresByType text/xml                              "access plus 0 seconds"

  # Favicon (cannot be renamed!) and cursor images
    ExpiresByType image/x-icon                          "access plus 1 week"

  # HTML components (HTCs)
    ExpiresByType text/x-component                      "access plus 1 month"

  # HTML
    ExpiresByType text/html                             "access plus 0 seconds"

  # JavaScript
    ExpiresByType application/javascript                "access plus 1 year"

  # Manifest files
    ExpiresByType application/x-web-app-manifest json   "access plus 0 seconds"
    ExpiresByType text/cache-manifest                   "access plus 0 seconds"

  # Media
    ExpiresByType audio/ogg                             "access plus 1 month"
    ExpiresByType image/gif                             "access plus 1 month"
    ExpiresByType image/jpeg                            "access plus 1 month"
    ExpiresByType image/png                             "access plus 1 month"
    ExpiresByType video/mp4                             "access plus 1 month"
    ExpiresByType video/ogg                             "access plus 1 month"
    ExpiresByType video/webm                            "access plus 1 month"

  # Web feeds
    ExpiresByType application/atom xml                  "access plus 1 hour"
    ExpiresByType application/rss xml                   "access plus 1 hour"
</IfModule>

网站是https://www.gandi.net/的主机,我发现有Varnish缓存系统阻止了我的更改的可见性。

以下是我从浏览器调用以清除特定网址缓存的PHP脚本 - 来自this链接:

<?php
/* purge.php
 * Purge a URL on this host
 */
header("Cache-Control: max-age=1"); // don't cache ourself
 
error_reporting(E_ALL);
ini_set("display_errors", 1);
 
// Set to true to hide varnish result
define("SILENT", false);
 
$path = isset($_GET["path"]) ? $_GET["path"] : "";
 
$purge_url = "http://" . $_SERVER["HTTP_HOST"] . "/$path";
 
if ( $ch = curl_init($purge_url) ) {
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PURGE");
    curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
    curl_setopt($ch, CURLOPT_NOBODY, SILENT);
 
    curl_exec($ch);
    curl_close($ch);
}
?>

然后我注意到我的网站没有使用Varhish进行缓存,因为Age为0.请参阅here http://image.prntscr.com/image/eacd88658f8a43d8a71b21a8109797b3.png

但不会显示更改。你有什么想法吗?

0 个答案:

没有答案