Note that there are some explanatory texts on larger screens.

plurals
  1. POCaching authenticated resources using Varnish
    primarykey
    data
    text
    <p>Our firm uses an application internally that serves more or less static content to all authenticated users. The application is built such that all its resources (js, css, images, html pages) are authenticated. Sadly, I can't seem to get Varnish working for caching authenticated resources. If I make the resource unauthenticated and use the following VCL configuration, things work:</p> <pre><code>backend default { .host = "****"; .port = "****"; } sub vcl_recv { if (req.url ~ "^/js" || req.url ~ "^/css" || req.url ~ "^/images") { unset req.http.cookie; } } sub vcl_fetch { if (req.url ~ "^/js" || req.url ~ "^/css" || req.url ~ "^/images") { unset beresp.http.set-cookie; } } </code></pre> <p>However, I'm looking to cache despite the resource being authenticated which I understand is not Varnish's default behaviour. Trying </p> <pre><code>if (req.http.Authorization) { return(lookup); } </code></pre> <p>in vcl_recv hasn't helped. Unsetting Authorization headers doesn't help either (application's authentication gets messed up).</p> <p>I get the following varnish logs (b- backend calls still happen):</p> <pre><code>14 TxURL b /_search 14 TxHeader b Content-Type: application/x-www-form-urlencoded 15 RxURL c /_search 15 RxHeader c Content-Type: application/x-www-form-urlencoded 14 TxURL b /admin 14 TxHeader b Content-Type: application/x-www-form-urlencoded 17 RxURL c /admin 17 RxHeader c Content-Type: application/x-www-form-urlencoded 15 RxURL c /_search 15 RxHeader c Content-Type: application/x-www-form-urlencoded 17 RxURL c /admin 17 RxHeader c Content-Type: application/x-www-form-urlencoded 14 TxURL b /js/all.js?_=1385100392830 17 RxURL c /js/all.js?_=1385100392830 </code></pre> <p>Adding the HTTP request and response headers:</p> <p><strong>Request Headers:</strong></p> <pre><code>Host: ****.com Connection: keep-alive Authorization: Negotiate YIIVTAYGKwYBBQUCoIIVQDCCFTygMDAuBgkqhkiC9xIBAgIGCSqGSIb3EgECAgYKK Accept: */* User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36 Referer: **** Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8 </code></pre> <p><strong>Response Headers:</strong></p> <pre><code>Cache-Control: public, max-age=86400 Transfer-Encoding: chunked Content-Type: application/x-javascript Content-Encoding: gzip Last-Modified: Sat, 10 Nov 2012 08:32:01 GMT Accept-Ranges: bytes ETag: "{6B28BC5E-71C3-4A1B-9D3C-1DA5EA161F96},2pub" Vary: Accept-Encoding Server: Microsoft-IIS/7.5 SPRequestGuid: 8864bca5-d7cb-4ac0-bbe8-3a64391ca70f X-AspNet-Version: 2.0.50727 WWW-Authenticate: Negotiate oYGzMIGwoAMKAQChCwYJKoZIgvcSAQICooGbBIGYYIGVBgkqhkiG9xIBAgICAG+BhTCBgqADAgEFoQMCAQ+idjB Persistent-Auth: true X-Powered-By: ASP.NET MicrosoftSharePointTeamServices: 14.0.0.6137 X-MS-InvokeApp: 1; RequireReadOnly Date: Tue, 26 Nov 2013 15:43:46 GMT </code></pre> <p>Can someone please provide me a VCL config snippet that can help?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload