我有一個Drupal 7安裝,有時會將圖像的src路徑設置爲127.0.0.1。 這裏是一個例子。Drupal 7和清漆圖像緩存設置src爲127.0.0.1
<img height="291" width="233" style="width: 233px; height: 291px; float: left;" class="media-image media-element file-default" typeof="foaf:Image" src="http://127.0.0.1/sites/default/files/media/news/images/jerzy_sawicki.jpg" alt="" title="">
清除緩存後,圖像src是正確的一段時間。
<img height="291" width="233" style="width: 233px; height: 291px; float: left;" class="media-image media-element file-default" typeof="foaf:Image" src="http://www.example.com/sites/default/files/media/news/images/jerzy_sawicki.jpg" alt="" title="">
我有許多貢獻模塊啓用,但我想這可能是一個光油或緩存過期問題。
這是varnish default.vcl配置。我已經將127.0.0.1更改爲可能影響src的服務器名稱,但它沒有。
backend default {
.host = "www.example.com";
.port = "8888";
.connect_timeout = 10s;
.first_byte_timeout = 10s;
.between_bytes_timeout = 10s;
// Check Drupal every 5 minutes to keep cache warm.
.probe = {
.url = "/news";
.interval = 300s;
.timeout = 10s;
.window = 5;
.threshold = 2;
}
}
sub vcl_recv {
// Remove has_js and Google Analytics __* cookies.
set req.http.Cookie = regsuball(req.http.Cookie, "(^|;\s*)(__[a-z]+|has_js)=[^;]*", "");
// Remove a ";" prefix, if present.
set req.http.Cookie = regsub(req.http.Cookie, "^;\s*", "");
// Remove empty cookies.
if (req.http.Cookie ~ "^\s*$") {
unset req.http.Cookie;
}
// Catch Drupal theme files – THIS BREAKS UPDATE.PHP
if (req.url ~ "^/sites/") {
unset req.http.Cookie;
}
// Catch Drupal misc files (like drupal.js and jquery.js)
if (req.url ~ "^/misc/") {
unset req.http.Cookie;
}
// Drupal js/css doesn’t need cookies, cache them
if (req.url ~ "^/modules/.*\.(js|css)\?") {
unset req.http.Cookie;
}
// Pass cron jobs
if (req.url ~ "cron.php" ||
req.url ~ "^/admin/structure/features$" ||
req.url ~ "^/admin/config/system/backup_migrate$") {
return (pass);
}
// Currently we have server-status monitoring going directly against 8888 port
// Commenting out this pass-through
//if (req.url ~ ".*/server-status$") {
//return (pass);
//}
# Add a unique header containing the client address
remove req.http.X-Forwarded-For;
set req.http.X-Forwarded-For = client.ip;
}
sub vcl_hash {
if (req.http.Cookie) {
set req.hash += req.http.Cookie;
}
}
sub vcl_deliver {
if (obj.hits > 0) {
set resp.http.X-Cache = "HIT";
} else {
set resp.http.X-Cache = "MISS";
}
}
sub vcl_fetch {
# Varnish determined the object was not cacheable
if (!beresp.cacheable) {
set beresp.http.X-Cacheable = "NO:Not Cacheable";
# You don't wish to cache content for logged in users
} elsif (req.http.Cookie ~ "(UserID|_session)") {
set beresp.http.X-Cacheable = "NO:Got Session";
return(pass);
# You are respecting the Cache-Control=private header from the backend
} elsif (beresp.http.Cache-Control ~ "private") {
set beresp.http.X-Cacheable = "NO:Cache-Control=private";
return(pass);
# You are extending the lifetime of the object artificially
} elsif (beresp.ttl < 1s) {
set beresp.ttl = 5s;
set beresp.grace = 5s;
set beresp.http.X-Cacheable = "YES:FORCED";
# Varnish determined the object was cacheable
} else {
set beresp.http.X-Cacheable = "YES";
}
# ....
return(deliver);
sub vcl_error {
# If 503 error and we've tried less than 3 times, try again
if (obj.status == 503 && req.restarts < 3) {
restart;
}
}
感謝您的信息。我會給新配置一個鏡頭。我已將Varnish更新爲v.3。我們有2.1(RHEL 6默認可用)。 – bart