J'avais un default.vcl de base pour mon site Web et cela fonctionnait.Après avoir ajouté mobile détecter dans le vernis {default.vcl}, le vernis ne démarre pas
J'ai ajouté le code ci-dessous pour détecter et servir un thème différent pour l'utilisateur si le formulaire est à venir sur pc ou mobile. Après avoir ajouté le code ci-dessous pour détecter le périphérique mobile, le vernissage ne démarre pas.
Comment puis-je résoudre ce si vernis détecte l'appareil mobile et donc le thème mobile est servi dans la même url si visité de mobile, table
/*
*
* First, set up a backend to answer the request if there's not a cache hit.
*
*/
backend default {
# Set a host.
.host = "xx.xx.xx.xx";
# Set a port. 80 is normal Web traffic.
.port = "xxxx";
}
/*
*
* Next, configure the "receive" subroutine.
*
*/
acl admin_ip {
"xx.xx.xx.xx";
}
include "devicedetect.vcl";
sub vcl_recv {
call devicedetect;
if (req.request == "PURGE") {
if (!client.ip ~ admin_ip) {
error 405 "You can't do this, muggle!";
}
return(lookup);
}
if (!req.backend.healthy) {
unset req.http.Cookie;
}
set req.http.X-Forwarded-For = client.ip;
# Use the backend we set up above to answer the request if it's not cached.
#set req.backend = default;
if (req.url ~ "^/user/login" ||
req.url ~ "^/oc-admin" ||
req.url ~ "^/item/new" ||
req.request == "POST")
{
return (pass);
}
if (req.url ~ "(?i)\.(pdf|asc|dat|txt|doc|xls|ppt|tgz|csv|png|gif|jpeg|jpg|ico|swf|css|js)(\?.*)?$") {
unset req.http.Cookie;
unset req.http.Cache-Control;
unset req.http.Max-Age;
unset req.http.Pragma;
unset req.http.Cookie;
}
if(req.http.Cookie) {
if (req.http.Cookie !~ "(sessionid|XXXid)") {
remove req.http.Cookie;
}
}
# Pass the request along to lookup to see if it's in the cache.
return(lookup);
}
/*
*
* Next, let's set up the subroutine to deal with cache misses.
*
*/
sub vcl_miss {
# We're not doing anything fancy. Just pass the request along to the
# subroutine which will fetch something from the backend.
return(fetch);
}
/*
*
* Now, let's set up a subroutine to deal with cache hits.
*
*/
sub vcl_hit {
# Again, nothing fancy. Just pass the request along to the subroutine
# which will deliver a result from the cache.
return(deliver);
}
/*
*
* This is the subroutine which will fetch a response from the backend.
* It's pretty fancy because this is where the basic logic for caching is set.
*
*/
sub vcl_fetch {
if (req.http.X-UA-Device) {
if (!beresp.http.Vary) { # no Vary at all
set beresp.http.Vary = "X-UA-Device";
} elseif (beresp.http.Vary !~ "X-UA-Device") { # add to existing Vary
set beresp.http.Vary = beresp.http.Vary + ", X-UA-Device";
}
}
#unset beresp.http.expires; # for cloudfront since it prefers cache-control
# header over expires
if (req.url ~ "(?i)\.(pdf|asc|dat|txt|doc|xls|ppt|tgz|csv|png|gif|jpeg|jpg|ico|swf|css|js)(\?.*)?$") {
unset beresp.http.set-cookie;
}
if (req.http.Content-Type ~ "(image|audio|video|pdf|flash)") {
set beresp.do_gzip = false;
}
if (req.http.Content-Type ~ "text") {
set beresp.do_gzip = true;
}
# Varnish determined the object was not cacheable
if (beresp.ttl 0) {
set resp.http.X-Varnish-Cache = "HIT";
}
else {
set resp.http.X-Varnish-Cache = "MISS";
}
return (deliver);
}
après avoir utilisé la commande mention ci-dessus, il m'a montré comme erreur dans
# Varnish determined the object was not cacheable if (beresp.ttl 0) { set resp.http.X-Varnish-Cache = "HIT"; } else { set resp.http.X-Varnish-Cache = "MISS"; }
alors je change cela (beresp.ttl 0 as (beresp.ttl> = 0s) et que le vernis a commencé mais il n'est rien cahier –le périphérique détecter vcl est [link] (https://github.com/varnishcache/varnish-devicedetect/blob/master/devicedetect.vcl) –