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
5
votes
2 answers

Varnish: how to separately cache pages based on value of a specific cookie

I manage a site that has a single cookie, which we have to use, but will always be one of 9 values (including no value). I'd like to use varnish in front of our application servers, with varnish separately caching a version of each page based on the…
Matt
  • 227
  • 2
  • 11
5
votes
2 answers

Magento Multi language store with varnish

How Multi-Language Magento store work with Varnish. Is there any configuration available in varnish,so we can create cache base on cookies?
Kandarp B Patel
  • 1,062
  • 10
  • 28
5
votes
1 answer

replacing content in a page with varnish + regex

If I want my varnish cache server to replace content inside a page (ie: change the class on a div) from the backend before serving or storing the page (vcl_fetch?), how can this be done? I would like to use simple regex to perform the replacement as…
tweak2
  • 646
  • 5
  • 15
5
votes
1 answer

varnish 503 service unavailable

My varnish version is 3.0. My server works well while I curl the URLs, but when use varnish cache it return 503 service unavailable occasionally. The log info likes is: 0 Debug - "VCL_error(200, OK)" 24 VCL_call c recv error 24 VCL_call …
lichengwu
  • 4,277
  • 6
  • 29
  • 42
4
votes
2 answers

Varnish vcl_hash to remove a parameter

I'm using Varnish 2.0.6 and I'm having trouble with finding good documentation to write the vcl_hash function. I need to remove a few parameters from the URL of my API before caching. In particular a userid that is passed to track analytics but not…
robsf
  • 1,713
  • 3
  • 14
  • 26
4
votes
1 answer

Defining lists in VCL (Varnish Configuration Language)

Is there a way to define lists of domains in Varnish VCL language? I suppose something similar for ACLs. I would like to do something like this (using ACLs as an example). acl website_list { '(www\.)?domain.tld'; …
rATRIJS
  • 309
  • 1
  • 5
4
votes
1 answer

Varnish default grace behavior

Have some api resources that are under heavy load, where responses are dynamic and to offload the origin servers we are using Varnish as a caching layer in front. The api responds with cache-control headers ranging from max-age=5 to max-age=15.…
flalar
  • 1,181
  • 3
  • 12
  • 23
4
votes
1 answer

Varnish HTC status -1

I'm currently facing some random 503-errors on my Varnish and I can't figure out where they come from. The FetchError is the following: HTC Status -1, which means HTC_S_EOF see here Somehow, the bereq instantly failes and there is not even a single…
Hermsi1337
  • 241
  • 2
  • 9
4
votes
0 answers

Make varnish cache a synthetic response for failing ESI

We use varnish 4 for caching and processing ESI. For ESI requests that return a 5XX backend error, we return an empty synthetic response. That empty response should be cached for a few seconds, because currently every subsequent request to the same…
simon.ro
  • 2,984
  • 2
  • 22
  • 36
4
votes
2 answers

How to escape a double quote in varnish vcl

In vcl_recv I'm trying to send a 403 to requests that contain the following characters in the url: ",',<,>,(, and ) if(req.url ~ "[\'\<\>()].*\.html" ) { return (synth(403, "Forbidden")); } everything works except the double quote " I tried regex…
4
votes
1 answer

Varnish List all URLS in Cache

i am looking for a way to iterate over the whole cache and get a list of object URL's - that are currently inside the storage. is there any varnish command i am missing. or does anyone have a good starting poiunt for iterating over objects from…
Helmut Januschka
  • 1,578
  • 3
  • 16
  • 34
4
votes
1 answer

What does hash_data vcl_hash do?

Can someone explain the following vcl code: sub vcl_hash { hash_data(req.url); if (req.http.host) { hash_data(req.http.host); } else { hash_data(server.ip); } if (req.http.Cookie) { …
John Roca
  • 1,204
  • 1
  • 14
  • 27
4
votes
0 answers

Varnish 4 add ban on vcl_backend_response with some specific header

I have an Restful API with Varnish cache server over and I want to ban a specific endpoint from the backend, through some http headers. To be more specific I will give an example: I have updated an entity with some data, like: (PUT)…
birkof
  • 634
  • 1
  • 6
  • 14
4
votes
1 answer

How do I make Varnish 4 cache everything regardless of cache-control headers and cookies

In a nutshell, I am trying if (beresp.ttl < 120s) { set beresp.ttl = 120s; unset beresp.http.Cache-Control; } In my VCL config file and it's not working. More detail below: Here is my request…
Hard worker
  • 3,916
  • 5
  • 44
  • 73
4
votes
2 answers

How can I view the contents of Varnish's hash_data()?

I know that in Varnish you can add data to the cache hash using hash_data() within vcl_hash, as per the docs. For debugging purposes, I would like to be able to see the entire contents of whatever is making up the hash. For example, it would be…
rangfu
  • 6,878
  • 2
  • 16
  • 17
1 2
3
45 46