Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7611949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:47:31+00:00 2026-05-31T01:47:31+00:00

After started Varnish, I visited the website once. After populating all pages, revisiting all

  • 0

After started Varnish, I visited the website once. After populating all pages, revisiting all the pages become so fast.

But when I switch to another computer and visit the site, it seems I have to start again this cache populating process.

So it seems that Varnish is not serving cached pages cached by the other user

I hope that I have addressed my question clearly.

Does anyone knows what happened.

Here is the vcl file

backend Tserver {
   .host = "127.0.0.1";
   .port = "8080";
}

acl purge {
   "localhost";
   "127.0.0.1";
   "192.168.3.0"/24;
}

sub vcl_recv {
   if (req.request == "PURGE") {
           if (!client.ip ~ purge) {
                   error 405 "Not allowed.";
           }
           return(lookup);
   }

   #without this, the whole logged in status is messed up
   remove req.http.X-Forwarded-For;
   set req.http.X-Forwarded-For = client.ip;

   // Remove has_js and Google Analytics cookies
   set req.http.Cookie = regsuball(req.http.Cookie, "(^|;\s*)(_[_a-z]+|has_js)=[^;]*","");

   #if(req.http.Authorization || req.http.Cookie) {
   #  /* Not cachable by default */
   #  return (pass);
   #}

   // 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;
   #}

   // Skip the Vanish cache for install, update, and cron
   if (req.url ~ "install\.php|update\.php|cron\.php") {
     return (pass);
   }


   # Normalize Accept-Encoding to get better cache coherency
   if (req.http.Accept-Encoding) {
     # No point in compressing media that is already compressed
     if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$") {
       remove req.http.Accept-Encoding;
       # MSIE 6 JS bug workaround
     } elsif(req.http.User-Agent ~ "MSIE 6") {
       unset req.http.Accept-Encoding;
     } elsif (req.http.Accept-Encoding ~ "gzip") {
       set req.http.Accept-Encoding = "gzip";
     } elsif (req.http.Accept-Encoding ~ "deflate") {
       set req.http.Accept-Encoding = "deflate";
     } else {
       # unkown algorithm
       remove req.http.Accept-Encoding;
     }
   }

   #if (req.url ~ "^/classifieds") {
   #  return(pipe);
   #}

   #if (req.url ~ "^/logout") {
   #  return(pipe);
   #}

   #if (req.url ~ "^/admin") {
   #  return(pipe);
   #}

   # Remove the incoming Cookie header from anonymous requests
   # This is from Drupal 7 book, not sure if this works here
   #if (req.http.Cookie !~ "(^|;\s*)SESS") {
   #  unset req.http.Cookie;
   #}
/*
  if (req.http.Cookie) {
    set req.http.Cookie = ";" req.http.Cookie;
    set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";");
    set req.http.Cookie = regsuball(req.http.Cookie, ";(LOGGED_IN|VARNISH)=", "; \1=");
    set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", "");
    set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", "");

    if (req.http.Cookie == "") {
        remove req.http.Cookie;
    }
  }
*/

   # ... other vcl_recv rules here ...
   # Don't serve cached content to logged-in users
   # Don't cache Drupal logged-in user sessions
   # LOGGED_IN is the cookie that earlier version of Pressflow sets
   # VARNISH is the cookie which the varnish.module sets

   if (req.http.Cookie ~ "(VARNISH|DRUPAL_UID|LOGGED_IN)") {
     return (pipe);
   }

   // Let's have a little grace
   // When backend cannot generate refreshed content
   // this time will allow expired content to stay longer in grace
   set req.grace = 0s;

   if (req.http.host ~ "^www.test1.com") {
           set req.backend = Tserver;
           if (req.request != "GET" && req.request != "HEAD") {
                   return(pipe);
           }
           else {
                   return(lookup);
           }
   }elsif (req.http.host ~ "^www.test2.com") {
           set req.backend = Tserver;
           if (req.request != "GET" && req.request != "HEAD") {
                   return(pipe);
           }
           else {
                   return(lookup);
           }
   }
   else {
           error 404 "T Cache Server IS Out of Order";
           return(lookup);
   }

   # Drupal js/css doesn't need cookies, cache them
   if (req.url ~ "^/modules/.*\.(js|css)\?") {
           unset req.http.Cookie;
   }


   ## Pass cron jobs and server-status
   if (req.url ~ "cron.php") {
           return (pass);
   }
   if (req.url ~ ".*/server-status$") {
           return (pass);
   }

}

sub vcl_hash {
  if (req.http.Cookie) {
    set req.hash += req.http.Cookie;
  }
}

sub vcl_hit {
   if (req.http.Cookie ~ "LOGGED_IN") {
           set obj.ttl = 0s;
           return (pass);
   }

   if (req.request == "PURGE") {
           set obj.ttl = 0s;
           error 200 "Purged.";
   }
}

sub vcl_miss {
   if (req.request == "PURGE") {
           error 404 "Not in cache.";
   }
}

sub vcl_fetch {
   if (req.url ~ "\.(png|gif|jpg|swf|css|js)$") {
     unset beresp.http.set-cookie;
   }


   #if (beresp.http.Pragma ~ "nocache") {
   #  return(pass);
   #}

   if (req.request == "GET" && req.url ~ "\.(txt|js)$") {
          set beresp.ttl = 3600s;
   }
   elseif (req.http.Cookie ~ "LOGGED_IN") {
          set beresp.ttl = 0s;
  }
  else {
          // cache time is 30 days then in varnish
          set beresp.ttl = 30d;
   }

}

sub vcl_error {
  set obj.http.Content-Type = "text/html; charset=utf-8";
  set obj.http.Retry-After = "5";
  synthetic {"<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html><head><title>"} obj.status " " obj.response {"</title></head><body><h1>Error "} obj.status " " obj.response {"</h1><p>"} obj.response {"</p><h3>Guru Meditation:</h3><p>XID: "} req.xid {"</p><hr><p>Varnish cache server</p></body></html>"};
  return (deliver);
}

sub vcl_pipe {
  # http://www.varnish-cache.org/ticket/451
  # This forces every pipe request to be the first one.
  set bereq.http.connection = "close";
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:47:32+00:00Added an answer on May 31, 2026 at 1:47 am

    Do you have a user-specific (session) cookie, even if the user is logged out?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After following the RoR getting started tutorial, I added another model as: $ rails
I use Passenger to start my Rails app, but after I started Nginx, Rails
After having started a Drag & Drop operation by DragDrop.DoDragDrop(...) no more MouseMove Events
Started learning Wicket after ASP.NET MVC and feel a little bit confused about managing
After a long investigation on how to use TFS 2010 I started with the
After the release of MVC 2, I have started to check and play with
I recently started reading about ASP.net MVC and after getting excited about the concept,
I just started learning ASP.NET MVC4 today. After reading tutorials, downloading VS 2012, and
I started trying to set up a local rails installation for development. After I
I started cloning an SVN repository using the git-svn's clone operation. After about 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.