title: Varnish - 2 projects different behaviour
body: <p>I have 2 django projects, setup basically the same. They both are a News/Article page, and the problem is with the second one. The first project caches correctly (index page and article page), although the second one caches only the home page, for example:</p>
  
  <p>Project 1 Home page:</p>
  
  <pre><code>curl -X PURGE http://teste.infalms.com.br/ (response: 200[hit] purged)
  </code></pre>
  
  <p>Project 1 Article page:</p>
  
  <pre><code>curl -X PURGE http://teste.infalms.com.br/noticias/variedades/pqp-hein/ (response: 200[hit] purged)
  </code></pre>
  
  <p>Project 2 Home page:</p>
  
  <pre><code>curl -X PURGE http://pcmag.infalms.com.br/ (response: 200[hit]
  </code></pre>
  
  <p>Project 2 Article page (404 [miss] Not in cache.):</p>
  
  <pre><code>curl -X PURGE http://pcmag.infalms.com.br/noticias/google-street-view-continua-capturando-momentos-estranhos/ 404 [miss] Not in cache.
  </code></pre>
  
  <p>Here is my default.vcl:</p>
  
  <pre><code>backend teste {
      .host = "127.0.0.1";
      .port = "8080";
  }
  
  acl purge {
      "localhost";
      "127.0.0.1";
      "198.58.107.57";
  }
  
  sub vcl_recv {
  # unless sessionid/csrftoken is in the request, don't pass ANY cookies (referral_source,     utm, etc)
  if (req.request == "GET" &amp;&amp; (req.url ~ "^/static" || (req.http.cookie !~ "sessionid" &amp;&amp; req.http.cookie !~ "csrftoken"))) {
      remove req.http.Cookie;
  }
  
  # normalize accept-encoding to account for different browsers
  # see: https://www.varnish-cache.org/trac/wiki/VCLExampleNormalizeAcceptEncoding
  if (req.http.Accept-Encoding) {
      if (req.http.Accept-Encoding ~ "gzip") {
          set req.http.Accept-Encoding = "gzip";
      } elsif (req.http.Accept-Encoding ~ "deflate") {
          set req.http.Accept-Encoding = "deflate";
      } else {
          # unknown algorithm
          remove req.http.Accept-Encoding;
      }
  }
  
  # allow PURGE from localhost and 192.168.55...
      if (req.request == "PURGE") {
          if (!client.ip ~ purge) {
              error 405 "Not allowed.";
          }
          return (lookup);
      }
  
      if (req.request == "BAN") {
          ban("obj.http.x-url ~ " + req.http.x-ban-url + 
          " &amp;&amp; obj.http.x-host ~ " + req.http.x-ban-host);
          error 200 "Banned";
      }
  
      if (req.request == "REFRESH") {
          set req.request = "GET";
          set req.hash_always_miss = true;
      }
  
      if (req.http.host ~ "pgadmin.infalms.com.br" || req.url ~ "admin" || req.http.host ~ "mediatarget.com.br" || req.http.host ~ "www.mediatarget.com.br")  {
          return(pass);
      }
  }
  
  sub vcl_fetch {
      if (beresp.ttl &gt; 0s) {
          /* Remove Expires from backend, it's not long enough */
          unset beresp.http.expires;
  
          /* Set the clients TTL on this object */
          set beresp.http.cache-control = "max-age=900";
  
          /* Set how long Varnish will keep it */
          set beresp.ttl = 1w;
  
          /* marker for vcl_deliver to reset Age: */
          set beresp.http.magicmarker = "1";
      }
  
  # static files always cached
      if (req.url ~ "^/static") {
          unset beresp.http.set-cookie;
          return (deliver);
      }
  
      # pass through for anything with a session/csrftoken set
      if (beresp.http.set-cookie ~ "sessionid" || beresp.http.set-cookie ~ "csrftoken") {
          return (hit_for_pass);
      } else {
          return (deliver);
      }
  }
  
  sub vcl_deliver {
      if (resp.http.magicmarker) {
         /* Remove the magic marker */
         unset resp.http.magicmarker;
  
         /* By definition we have a fresh object */
          set resp.http.age = "0";
      }
  }
  
  sub vcl_hit {
      if (req.request == "PURGE") {
          purge;
          error 200 "[hit] Purged.";
      }
  }
  
  sub vcl_miss {
      if (req.request == "PURGE") {
          purge;
          error 404 "[miss] Not in cache.";
      }
  }
  </code></pre>
  
  <p>There's another problem with Varnish, which is the fact that some images are not cached and not loading at all. Like this one:</p>
  
  <pre><code>http://pcmag.infalms.com.br/media/oldsite_imgs/bodytext_img_862920.jpg
  </code></pre>
  
  <p>When I try to purge it, it returns a [404]Miss. It loads sometimes if I keep pressing F5, but it's totally random.</p>