Questions tagged [varnish-vcl]

The Varnish Configuration Language (VCL) is a small domain-specific language used to define request handling and caching policies for the Varnish HTTP accelerator. Do not confuse this with the Visual Component Library (VCL) used in Delphi and C++Builder. Use the "vcl" tag for questions related to those products.

The VCL language is a small domain-specific language designed to be used to define request handling and document caching policies for the Varnish HTTP accelerator. When a new configuration is loaded, the varnishd management process translates the VCL code to C and compiles it to a shared object which is then dynamically linked into the server process.

The VCL documentation can be found on the documentation site.

677 questions
4
votes
4 answers

varnish vcl purging cache selectively

So i am using varnish for the first time. i have spent quite some time reading on how it works, but i am unable to figure out how do i selectively purge the cache. like say i have a url like this /?account=123&url=google.com and another…
Amit
  • 3,952
  • 7
  • 46
  • 80
3
votes
0 answers

Varnish MISS cache and Varnish control terminal is not responding at 192.168.56.102 on port 6082

I am using varnish on one box (192.168.56.102) and apache on other box (192.168.56.105). on varnish box - in /etc/varnish/default.vcl backend default { .host = "192.168.56.105"; .port = "80"; } and /etc/default/varnish DAEMON_OPTS="-a :80 \ …
bee
  • 393
  • 1
  • 6
  • 18
3
votes
1 answer

How to declare a variable that persists subroutines

During the recv subroutine I am currently changing my backend to another backend to handle the request, I need to declare a variable that will hold the value for the first/original backend that it was set to, so that when the request is restarted, I…
C. Dodds
  • 325
  • 3
  • 12
3
votes
1 answer

How to ignore specific query parameter with varnish cache?

/swatches/ajax/media/?product_id=17620&isAjax=true&_=1524469655019 I need to cache this request with varnish, but i need to ignore the last query parameter _=1524469655019. I am not sure how varnish internally works, but i suppose it makes the…
Tanel Tammik
  • 15,489
  • 3
  • 22
  • 31
3
votes
0 answers

Varnish how to cache on public cache-control header

I just started updating my VCL and found a good boilerplate on the web: https://github.com/mattiasgeniar/varnish-5.0-configuration-templates/blob/master/default.vcl The only problem i have is that when i have a valid response header like…
Dirkos
  • 488
  • 1
  • 10
  • 33
3
votes
2 answers

Varnish 5.2 started reporting "500 Internal Server Error"

I have been running Varnish for some time and about 6 months ago I added a Varnish 5.2 server that has been running perfectly. A couple of weeks ago we have started to see odd "500 Internal Server Error" and when looking at older reports they…
Alan Jay
  • 151
  • 1
  • 11
3
votes
1 answer

Regex capture group in Varnish VCL

I have a URL in the form of: http://some-site.com/api/v2/portal-name/some/webservice/call The data I want to fetch needs http://portal-name.com/webservices/v2/some/webservice/call (Yes I can rewrite the application so it uses other URL's but we are…
Matthijs
  • 1,112
  • 2
  • 12
  • 28
3
votes
1 answer

ELB Keep-Alive Timeout: Varnish Configuration Assistance

I am looking to configure Varnish to optimize keep-alive timeout settings to work with my ELB. The ELB is using Varnish as the backend (providing caching for Tomcat). The keep-alive timeout value has been set within Tomcat for 120s. Testing this it…
Juzer
  • 31
  • 3
3
votes
1 answer

How to create custom function in default.vcl within Varnish?

I have repetitive code in my vcl and I want to create custom function without embedding inline C code. Is it possible?
3
votes
1 answer

Can I create a custom list of values like ACL in Varnish 4?

I'm using Varnish version 4. I'd like to know if VCL allows a custom and reusable list of values like ACL. I want to use it to check against visitors' cookies. If he is a moderator, don't serve cached content. Cookie String: …
RedGiant
  • 4,444
  • 11
  • 59
  • 146
3
votes
1 answer

varnish 4 grace time depending on backend health

I'm confused about where to set the grace time in varnish 4. I've seen example VCL's setting the grace time in vcl_recv sub vcl_recv { ... set req.http.grace = 60m; ... } others set it in vcl_hit sub vcl_hit { ... set obj.grace…
Matthias
  • 141
  • 9
3
votes
1 answer

Varnish 4 Hit Miss Header?

Does anyone have an updated hit miss header working for Varnish 4? Last one I found was for version 3. https://www.varnish-cache.org/trac/wiki/VCLExampleHitMissHeader#Varnish3.0 Looking for these: set beresp.http.X-Cacheable = "NO:Not Cacheable";…
adrelanos
  • 1,453
  • 2
  • 16
  • 27
3
votes
3 answers

Varnish include can't find file in the same directory

In my varnish default.vcl i have the following code: include "vars.vcl"; When i try to start my varnish i get this error message: Message from VCC-compiler: Cannot read file 'vars.vcl': No such file or directory ('input' Line 6 Pos 9) include…
Nafta
  • 71
  • 1
  • 7
3
votes
1 answer

Varnish 3 not parsing regex pattern correctly

I'm working on some code that generates PCRE patterns used to ban objects in varnish and having a problem with varnish telling me the pattern is invalid. This is one of the patterns generated by my code (?i)(((^| )page\-2[^ ]*($| ))) And this is…
Lee Saferite
  • 3,124
  • 22
  • 30
3
votes
2 answers

How banning in Varnish works?

I am not able to understand how banning works in Varnish. From the term and thinking of difference between purge and ban it seems that purge invalidates cache and next request goes to backend and gets cached again. BAN , bans a url. as in it…
Charanjeet Kaur
  • 1,199
  • 3
  • 14
  • 27