1VCL-VARIABLES(7) VCL-VARIABLES(7)
2
3
4
6 VCL-Variables - The complete album
7
9 This is a list of all variables in the VCL language.
10
11 Variable names take the form scope.variable[.index], for instance:
12
13 req.url
14 beresp.http.date
15 client.ip
16
17 Which operations are possible on each variable is described below, of‐
18 ten with the shorthand "backend" which covers the vcl_backend_* {} sub‐
19 routines and "client" which covers the rest, except vcl_init {} and
20 vcl_fini {}.
21
22 local, server, remote and client
23 These variables describe the network connection between the client and
24 varnishd.
25
26 Without PROXY protocol:
27
28 client server
29 remote local
30 v v
31 CLIENT ------------ VARNISHD
32
33 With PROXY protocol:
34
35 client server remote local
36 v v v v
37 CLIENT ------------ PROXY ------------ VARNISHD
38
39 local.ip
40 Type: IP
41
42 Readable from: client, backend
43
44 The IP address (and port number) of the local end of the TCP connec‐
45 tion, for instance 192.168.1.1:81
46
47 If the connection is a UNIX domain socket, the value will be
48 0.0.0.0:0
49
50 local.endpoint VCL >= 4.1
51 Type: STRING
52
53 Readable from: client, backend
54
55 The address of the '-a' socket the session was accepted on.
56
57 If the argument was -a foo=:81 this would be ":81"
58
59 local.socket VCL >= 4.1
60 Type: STRING
61
62 Readable from: client, backend
63
64 The name of the '-a' socket the session was accepted on.
65
66 If the argument was -a foo=:81 this would be "foo".
67
68 Note that all '-a' gets a default name on the form a%d if no name is
69 provided.
70
71 remote.ip
72 Type: IP
73
74 Readable from: client, backend
75
76 The IP address of the other end of the TCP connection. This can ei‐
77 ther be the clients IP, or the outgoing IP of a proxy server.
78
79 If the connection is a UNIX domain socket, the value will be
80 0.0.0.0:0
81
82 client.ip
83 Type: IP
84
85 Readable from: client, backend
86
87 The client's IP address, either the same as remote.ip or what the
88 PROXY protocol told us.
89
90 client.identity
91 Type: STRING
92
93 Readable from: client, backend
94
95 Writable from: client
96
97 Identification of the client, used to load balance in the client di‐
98 rector. Defaults to client.ip
99
100 This variable can be overwritten with more precise information, for
101 instance extracted from a Cookie: header.
102
103 server.ip
104 Type: IP
105
106 Readable from: client, backend
107
108 The IP address of the socket on which the client connection was re‐
109 ceived, either the same as server.ip or what the PROXY protocol told
110 us.
111
112 server.hostname
113 Type: STRING
114
115 Readable from: all
116
117 The host name of the server, as returned by the gethostname(3) sys‐
118 tem function.
119
120 server.identity
121 Type: STRING
122
123 Readable from: all
124
125 The identity of the server, as set by the -i parameter.
126
127 If an -i parameter is not passed to varnishd, the return value from
128 gethostname(3) system function will be used.
129
130 req and req_top
131 These variables describe the present request, and when ESI:include re‐
132 quests are being processed, req_top points to the request received from
133 the client.
134
135 req
136 Type: HTTP
137
138 Readable from: client
139
140 The entire request HTTP data structure. Mostly useful for passing
141 to VMODs.
142
143 req.method
144 Type: STRING
145
146 Readable from: client
147
148 Writable from: client
149
150 The request method (e.g. "GET", "HEAD", ...)
151
152 req.hash
153 Type: BLOB
154
155 Readable from: vcl_hit, vcl_miss, vcl_pass, vcl_purge, vcl_deliver
156
157 The hash key of this request. Mostly useful for passing to VMODs,
158 but can also be useful for debugging hit/miss status.
159
160 req.url
161 Type: STRING
162
163 Readable from: client
164
165 Writable from: client
166
167 The requested URL, for instance "/robots.txt".
168
169 req.proto VCL <= 4.0
170 Type: STRING
171
172 Readable from: client
173
174 Writable from: client
175
176 The HTTP protocol version used by the client, usually "HTTP/1.1" or
177 "HTTP/2.0".
178
179 req.proto VCL >= 4.1
180 Type: STRING
181
182 Readable from: client
183
184 The HTTP protocol version used by the client, usually "HTTP/1.1" or
185 "HTTP/2.0".
186
187 req.http.*
188 Type: HEADER
189
190 Readable from: client
191
192 Writable from: client
193
194 Unsetable from: client
195
196 The headers of request, things like req.http.date.
197
198 The RFCs allow multiple headers with the same name, and both set and
199 unset will remove all headers with the name given.
200
201 The header name * is a VCL symbol and as such cannot, for example,
202 start with a numeral. To work with valid header that can't be repre‐
203 sented as VCL symbols it is possible to quote the name, like
204 req.http."grammatically.valid". None of the HTTP headers present in
205 IANA registries need to be quoted, so the quoted syntax is discour‐
206 aged but available for interoperability.
207
208 req.restarts
209 Type: INT
210
211 Readable from: client
212
213 A count of how many times this request has been restarted.
214
215 req.storage
216 Type: STEVEDORE
217
218 Readable from: client
219
220 Writable from: client
221
222 The storage backend to use to save this request body.
223
224 req.esi_level
225 Type: INT
226
227 Readable from: client
228
229 A count of how many levels of ESI requests we're currently at.
230
231 req.ttl
232 Type: DURATION
233
234 Readable from: client
235
236 Writable from: client
237
238 Upper limit on the object age for cache lookups to return hit.
239
240 req.grace
241 Type: DURATION
242
243 Readable from: client
244
245 Writable from: client
246
247 Upper limit on the object grace.
248
249 During lookup the minimum of req.grace and the object's stored grace
250 value will be used as the object's grace.
251
252 req.xid
253 Type: STRING
254
255 Readable from: client
256
257 Unique ID of this request.
258
259 req.esi VCL <= 4.0
260 Type: BOOL
261
262 Readable from: client
263
264 Writable from: client
265
266 Set to false to disable ESI processing regardless of any value in
267 beresp.do_esi. Defaults to true. This variable is replaced by
268 resp.do_esi in VCL 4.1.
269
270 req.can_gzip
271 Type: BOOL
272
273 Readable from: client
274
275 True if the client provided gzip or x-gzip in the Accept-Encoding
276 header.
277
278 req.backend_hint
279 Type: BACKEND
280
281 Readable from: client
282
283 Writable from: client
284
285 Set bereq.backend to this if we attempt to fetch. When set to a di‐
286 rector, reading this variable returns an actual backend if the di‐
287 rector has resolved immediately, or the director otherwise. When
288 used in string context, returns the name of the director or backend,
289 respectively.
290
291 req.hash_ignore_busy
292 Type: BOOL
293
294 Readable from: client
295
296 Writable from: client
297
298 Default: false.
299
300 Ignore any busy object during cache lookup.
301
302 You only want to do this when you have two server looking up content
303 sideways from each other to avoid deadlocks.
304
305 req.hash_ignore_vary
306 Type: BOOL
307
308 Readable from: client
309
310 Writable from: client
311
312 Default: false.
313
314 Ignore objects vary headers during cache lookup.
315
316 This returns the very first match regardless of the object compati‐
317 bility with the client request. This is useful when variants are ir‐
318 relevant to certain clients, and differences in the way the resouce
319 is presented don't change how the client will interpret it.
320
321 Use with caution.
322
323 req.hash_always_miss
324 Type: BOOL
325
326 Readable from: client
327
328 Writable from: client
329
330 Default: false.
331
332 Force a cache miss for this request, even if perfectly good matching
333 objects are in the cache.
334
335 This is useful to force-update the cache without invalidating exist‐
336 ing entries in case the fetch fails.
337
338 req.is_hitmiss
339 Type: BOOL
340
341 Readable from: client
342
343 If this request resulted in a hitmiss
344
345 req.is_hitpass
346 Type: BOOL
347
348 Readable from: client
349
350 If this request resulted in a hitpass
351
352 req_top.method
353 Type: STRING
354
355 Readable from: client
356
357 The request method of the top-level request in a tree of ESI re‐
358 quests. (e.g. "GET", "HEAD"). Identical to req.method in non-ESI
359 requests.
360
361 req_top.url
362 Type: STRING
363
364 Readable from: client
365
366 The requested URL of the top-level request in a tree of ESI re‐
367 quests. Identical to req.url in non-ESI requests.
368
369 req_top.http.*
370 Type: HEADER
371
372 Readable from: client
373
374 HTTP headers of the top-level request in a tree of ESI requests.
375 Identical to req.http. in non-ESI requests.
376
377 See req.http.* for general notes.
378
379 req_top.proto
380 Type: STRING
381
382 Readable from: client
383
384 HTTP protocol version of the top-level request in a tree of ESI re‐
385 quests. Identical to req.proto in non-ESI requests.
386
387 bereq
388 This is the request we send to the backend, it is built from the
389 clients req.* fields by filtering out "per-hop" fields which should not
390 be passed along (Connection:, Range: and similar).
391
392 Slightly more fields are allowed through for pass` fetches than for
393 `miss` fetches, for instance ``Range.
394
395 bereq
396 Type: HTTP
397
398 Readable from: backend
399
400 The entire backend request HTTP data structure. Mostly useful as
401 argument to VMODs.
402
403 bereq.xid
404 Type: STRING
405
406 Readable from: vcl_pipe, backend
407
408 Unique ID of this request.
409
410 bereq.retries
411 Type: INT
412
413 Readable from: backend
414
415 A count of how many times this request has been retried.
416
417 bereq.backend
418 Type: BACKEND
419
420 Readable from: vcl_pipe, backend
421
422 Writable from: vcl_pipe, backend
423
424 This is the backend or director we attempt to fetch from. When set
425 to a director, reading this variable returns an actual backend if
426 the director has resolved immediately, or the director otherwise.
427 When used in string context, returns the name of the director or
428 backend, respectively.
429
430 bereq.body
431 Type: BODY
432
433 Unsetable from: vcl_backend_fetch
434
435 The request body.
436
437 Unset will also remove bereq.http.Content-Length.
438
439 bereq.hash
440 Type: BLOB
441
442 Readable from: vcl_pipe, backend
443
444 The hash key of this request, a copy of req.hash.
445
446 bereq.method
447 Type: STRING
448
449 Readable from: vcl_pipe, backend
450
451 Writable from: vcl_pipe, backend
452
453 The request type (e.g. "GET", "HEAD").
454
455 Regular (non-pipe, non-pass) fetches are always "GET"
456
457 bereq.url
458 Type: STRING
459
460 Readable from: vcl_pipe, backend
461
462 Writable from: vcl_pipe, backend
463
464 The requested URL, copied from req.url
465
466 bereq.proto VCL <= 4.0
467 Type: STRING
468
469 Readable from: vcl_pipe, backend
470
471 Writable from: vcl_pipe, backend
472
473 The HTTP protocol version, "HTTP/1.1" unless a pass or pipe request
474 has "HTTP/1.0" in req.proto
475
476 bereq.proto VCL >= 4.1
477 Type: STRING
478
479 Readable from: vcl_pipe, backend
480
481 The HTTP protocol version, "HTTP/1.1" unless a pass or pipe request
482 has "HTTP/1.0" in req.proto
483
484 bereq.http.*
485 Type: HEADER
486
487 Readable from: vcl_pipe, backend
488
489 Writable from: vcl_pipe, backend
490
491 Unsetable from: vcl_pipe, backend
492
493 The headers to be sent to the backend.
494
495 See req.http.* for general notes.
496
497 bereq.uncacheable
498 Type: BOOL
499
500 Readable from: backend
501
502 Indicates whether this request is uncacheable due to a pass in the
503 client side or a hit on an hit-for-pass object.
504
505 bereq.connect_timeout
506 Type: DURATION
507
508 Readable from: vcl_pipe, backend
509
510 Writable from: vcl_pipe, backend
511
512 Default: .connect_timeout attribute from the backend_definition,
513 which defaults to the connect_timeout parameter, see varnishd(1).
514
515 The time in seconds to wait for a backend connection to be estab‐
516 lished.
517
518 bereq.first_byte_timeout
519 Type: DURATION
520
521 Readable from: backend
522
523 Writable from: backend
524
525 Default: .first_byte_timeout attribute from the backend_definition,
526 which defaults to the first_byte_timeout parameter, see varnishd(1).
527
528 The time in seconds to wait getting the first byte back from the
529 backend. Not available in pipe mode.
530
531 bereq.between_bytes_timeout
532 Type: DURATION
533
534 Readable from: backend
535
536 Writable from: backend
537
538 Default: .between_bytes_timeout attribute from the backend_defini‐
539 tion, which defaults to the between_bytes_timeout parameter, see
540 varnishd(1).
541
542 The time in seconds to wait between each received byte from the
543 backend. Not available in pipe mode.
544
545 bereq.is_bgfetch
546 Type: BOOL
547
548 Readable from: backend
549
550 True for fetches where the client got a hit on an object in grace,
551 and this fetch was kicked of in the background to get a fresh copy.
552
553 bereq.is_hitmiss
554 Type: BOOL
555
556 Readable from: backend
557
558 If this backend request was caused by a hitmiss.
559
560 bereq.is_hitpass
561 Type: BOOL
562
563 Readable from: backend
564
565 If this backend request was caused by a hitpass.
566
567 beresp
568 The response received from the backend, one cache misses, the store ob‐
569 ject is built from beresp.
570
571 beresp
572 Type: HTTP
573
574 Readable from: vcl_backend_response, vcl_backend_error
575
576 The entire backend response HTTP data structure, useful as argument
577 to VMOD functions.
578
579 beresp.body
580 Type: BODY
581
582 Writable from: vcl_backend_error
583
584 For producing a synthetic body.
585
586 beresp.proto VCL <= 4.0
587 Type: STRING
588
589 Readable from: vcl_backend_response, vcl_backend_error
590
591 Writable from: vcl_backend_response, vcl_backend_error
592
593 The HTTP protocol version the backend replied with.
594
595 beresp.proto VCL >= 4.1
596 Type: STRING
597
598 Readable from: vcl_backend_response, vcl_backend_error
599
600 The HTTP protocol version the backend replied with.
601
602 beresp.status
603 Type: INT
604
605 Readable from: vcl_backend_response, vcl_backend_error
606
607 Writable from: vcl_backend_response, vcl_backend_error
608
609 The HTTP status code returned by the server.
610
611 More information in the HTTP response status section.
612
613 beresp.reason
614 Type: STRING
615
616 Readable from: vcl_backend_response, vcl_backend_error
617
618 Writable from: vcl_backend_response, vcl_backend_error
619
620 The HTTP status message returned by the server.
621
622 beresp.http.*
623 Type: HEADER
624
625 Readable from: vcl_backend_response, vcl_backend_error
626
627 Writable from: vcl_backend_response, vcl_backend_error
628
629 Unsetable from: vcl_backend_response, vcl_backend_error
630
631 The HTTP headers returned from the server.
632
633 See req.http.* for general notes.
634
635 beresp.do_esi
636 Type: BOOL
637
638 Readable from: vcl_backend_response, vcl_backend_error
639
640 Writable from: vcl_backend_response, vcl_backend_error
641
642 Default: false.
643
644 Set it to true to parse the object for ESI directives. This is nec‐
645 essary for later ESI processing on the client side. If beresp.do_esi
646 is false when an object enters the cache, client side ESI processing
647 will not be possible (obj.can_esi will be false).
648
649 It is a VCL error to use beresp.do_esi after setting beresp.filters.
650
651 beresp.do_stream
652 Type: BOOL
653
654 Readable from: vcl_backend_response, vcl_backend_error
655
656 Writable from: vcl_backend_response, vcl_backend_error
657
658 Default: true.
659
660 Deliver the object to the client while fetching the whole object
661 into varnish.
662
663 For uncacheable objects, storage for parts of the body which have
664 been sent to the client may get freed early, depending on the stor‐
665 age engine used.
666
667 This variable has no effect if beresp.do_esi is true or when the re‐
668 sponse body is empty.
669
670 beresp.do_gzip
671 Type: BOOL
672
673 Readable from: vcl_backend_response, vcl_backend_error
674
675 Writable from: vcl_backend_response, vcl_backend_error
676
677 Default: false.
678
679 Set to true to gzip the object while storing it.
680
681 If http_gzip_support is disabled, setting this variable has no ef‐
682 fect.
683
684 It is a VCL error to use beresp.do_gzip after setting beresp.fil‐
685 ters.
686
687 beresp.do_gunzip
688 Type: BOOL
689
690 Readable from: vcl_backend_response, vcl_backend_error
691
692 Writable from: vcl_backend_response, vcl_backend_error
693
694 Default: false.
695
696 Set to true to gunzip the object while storing it in the cache.
697
698 If http_gzip_support is disabled, setting this variable has no ef‐
699 fect.
700
701 It is a VCL error to use beresp.do_gunzip after setting beresp.fil‐
702 ters.
703
704 beresp.was_304
705 Type: BOOL
706
707 Readable from: vcl_backend_response, vcl_backend_error
708
709 When true this indicates that we got a 304 response to our condi‐
710 tional fetch from the backend and turned that into beresp.status =
711 200
712
713 beresp.uncacheable
714 Type: BOOL
715
716 Readable from: vcl_backend_response, vcl_backend_error
717
718 Writable from: vcl_backend_response, vcl_backend_error
719
720 Inherited from bereq.uncacheable, see there.
721
722 Setting this variable makes the object uncacheable.
723
724 This may may produce a hit-for-miss object in the cache.
725
726 Clearing the variable has no effect and will log the warning "Ignor‐
727 ing attempt to reset beresp.uncacheable".
728
729 beresp.ttl
730 Type: DURATION
731
732 Readable from: vcl_backend_response, vcl_backend_error
733
734 Writable from: vcl_backend_response, vcl_backend_error
735
736 Default: Cache-Control s-maxage or max-age directives, or a value
737 computed from the Expires header's deadline, or the default_ttl pa‐
738 rameter.
739
740 The object's remaining time to live, in seconds.
741
742 beresp.age
743 Type: DURATION
744
745 Readable from: vcl_backend_response, vcl_backend_error
746
747 Default: Age header, or zero.
748
749 The age of the object.
750
751 beresp.grace
752 Type: DURATION
753
754 Readable from: vcl_backend_response, vcl_backend_error
755
756 Writable from: vcl_backend_response, vcl_backend_error
757
758 Default: Cache-Control stale-while-revalidate directive, or de‐
759 fault_grace parameter.
760
761 Set to a period to enable grace.
762
763 beresp.keep
764 Type: DURATION
765
766 Readable from: vcl_backend_response, vcl_backend_error
767
768 Writable from: vcl_backend_response, vcl_backend_error
769
770 Default: default_keep parameter.
771
772 Set to a period to enable conditional backend requests.
773
774 The keep time is cache lifetime in addition to the ttl.
775
776 Objects with ttl expired but with keep time left may be used to is‐
777 sue conditional (If-Modified-Since / If-None-Match) requests to the
778 backend to refresh them.
779
780 beresp.backend
781 Type: BACKEND
782
783 Readable from: vcl_backend_response, vcl_backend_error
784
785 This is the backend we fetched from. If bereq.backend was set to a
786 director, this will be the backend selected by the director. When
787 used in string context, returns its name.
788
789 beresp.backend.name
790 Type: STRING
791
792 Readable from: vcl_backend_response, vcl_backend_error
793
794 Name of the backend this response was fetched from. Same as
795 beresp.backend.
796
797 beresp.backend.ip VCL <= 4.0
798 Type: IP
799
800 Readable from: vcl_backend_response
801
802 IP of the backend this response was fetched from.
803
804 beresp.storage
805 Type: STEVEDORE
806
807 Readable from: vcl_backend_response, vcl_backend_error
808
809 Writable from: vcl_backend_response, vcl_backend_error
810
811 The storage backend to use to save this object.
812
813 beresp.storage_hint VCL <= 4.0
814 Type: STRING
815
816 Readable from: vcl_backend_response, vcl_backend_error
817
818 Writable from: vcl_backend_response, vcl_backend_error
819
820 Deprecated since varnish 5.1 and discontinued since VCL 4.1 (varnish
821 6.0). Use beresp.storage instead.
822
823 Hint to Varnish that you want to save this object to a particular
824 storage backend.
825
826 beresp.filters
827 Type: STRING
828
829 Readable from: vcl_backend_response
830
831 Writable from: vcl_backend_response
832
833 List of Varnish Fetch Processor (VFP) filters the beresp.body will
834 be pulled through. The order left to right signifies processing from
835 backend to cache, iow the leftmost filter is run first on the body
836 as received from the backend after decoding of any transfer encod‐
837 ings.
838
839 VFP Filters change the body before going into the cache and/or being
840 handed to the client side, where it may get processed again by
841 resp.filters.
842
843 The following VFP filters exist in varnish-cache:
844
845 • gzip: compress a body using gzip
846
847 • testgunzip: Test if a body is valid gzip and refuse it otherwise
848
849 • gunzip: Uncompress gzip content
850
851 • esi: ESI-process plain text content
852
853 • esi_gzip: Save gzipped snippets for efficient ESI-processing
854
855 This filter enables stitching together ESI from individually
856 gzipped fragments, saving processing power for re-compression on
857 the client side at the expense of some compression efficiency.
858
859 Additional VFP filters are available from VMODs.
860
861 By default, beresp.filters is constructed as follows:
862
863 • gunzip gets added for gzipped content if beresp.do_gunzip or
864 beresp.do_esi are true.
865
866 • esi_gzip gets added if beresp.do_esi is true together with
867 beresp.do_gzip or content is already compressed.
868
869 • esi gets added if beresp.do_esi is true
870
871 • gzip gets added for uncompressed content if beresp.do_gzip is true
872
873 • testgunzip gets added for compressed content if beresp.do_gunzip
874 is false.
875
876 After beresp.filters is set, using any of the beforementioned
877 beresp.do_* switches is a VCL error.
878
879 obj
880 This is the object we found in cache. It cannot be modified.
881
882 obj.proto
883 Type: STRING
884
885 Readable from: vcl_hit
886
887 The HTTP protocol version stored in the object.
888
889 obj.status
890 Type: INT
891
892 Readable from: vcl_hit
893
894 The HTTP status code stored in the object.
895
896 More information in the HTTP response status section.
897
898 obj.reason
899 Type: STRING
900
901 Readable from: vcl_hit
902
903 The HTTP reason phrase stored in the object.
904
905 obj.hits
906 Type: INT
907
908 Readable from: vcl_hit, vcl_deliver
909
910 The count of cache-hits on this object.
911
912 In vcl_deliver a value of 0 indicates a cache miss.
913
914 obj.http.*
915 Type: HEADER
916
917 Readable from: vcl_hit
918
919 The HTTP headers stored in the object.
920
921 See req.http.* for general notes.
922
923 obj.ttl
924 Type: DURATION
925
926 Readable from: vcl_hit, vcl_deliver
927
928 The object's remaining time to live, in seconds.
929
930 obj.age
931 Type: DURATION
932
933 Readable from: vcl_hit, vcl_deliver
934
935 The age of the object.
936
937 obj.grace
938 Type: DURATION
939
940 Readable from: vcl_hit, vcl_deliver
941
942 The object's grace period in seconds.
943
944 obj.keep
945 Type: DURATION
946
947 Readable from: vcl_hit, vcl_deliver
948
949 The object's keep period in seconds.
950
951 obj.uncacheable
952 Type: BOOL
953
954 Readable from: vcl_deliver
955
956 Whether the object is uncacheable (pass, hit-for-pass or
957 hit-for-miss).
958
959 obj.storage
960 Type: STEVEDORE
961
962 Readable from: vcl_hit, vcl_deliver
963
964 The storage backend where this object is stored.
965
966 obj.can_esi
967 Type: BOOL
968
969 Readable from: vcl_hit, vcl_deliver
970
971 If the object can be ESI processed, that is if setting resp.do_esi
972 or adding esi to resp.filters in vcl_deliver {} would cause the re‐
973 sponse body to be ESI processed.
974
975 resp
976 This is the response we send to the client, it is built from either
977 beresp (pass/miss), obj (hits) or created from whole cloth (synth).
978
979 With the exception of resp.body all resp.* variables available in both
980 vcl_deliver{} and vcl_synth{} as a matter of symmetry.
981
982 resp
983 Type: HTTP
984
985 Readable from: vcl_deliver, vcl_synth
986
987 The entire response HTTP data structure, useful as argument to
988 VMODs.
989
990 resp.body
991 Type: BODY
992
993 Writable from: vcl_synth
994
995 To produce a synthetic response body, for instance for errors.
996
997 resp.proto VCL <= 4.0
998 Type: STRING
999
1000 Readable from: vcl_deliver, vcl_synth
1001
1002 Writable from: vcl_deliver, vcl_synth
1003
1004 The HTTP protocol version to use for the response.
1005
1006 resp.proto VCL >= 4.1
1007 Type: STRING
1008
1009 Readable from: vcl_deliver, vcl_synth
1010
1011 The HTTP protocol version to use for the response.
1012
1013 resp.status
1014 Type: INT
1015
1016 Readable from: vcl_deliver, vcl_synth
1017
1018 Writable from: vcl_deliver, vcl_synth
1019
1020 The HTTP status code that will be returned.
1021
1022 More information in the HTTP response status section.
1023
1024 resp.status 200 will get changed into 304 by core code after a re‐
1025 turn(deliver) from vcl_deliver for conditional requests to cached
1026 content if validation succeeds.
1027
1028 For the validation, first req.http.If-None-Match is compared against
1029 resp.http.Etag. If they compare equal according to the rules for
1030 weak validation (see RFC7232), a 304 is sent.
1031
1032 Secondly, req.http.If-Modified-Since is compared against
1033 resp.http.Last-Modified or, if it is unset, against the point in
1034 time when the object was last modified based on the Date and Age
1035 headers received with the backend response which created the object.
1036 If the object has not been modified based on that comparison, a 304
1037 is sent.
1038
1039 resp.reason
1040 Type: STRING
1041
1042 Readable from: vcl_deliver, vcl_synth
1043
1044 Writable from: vcl_deliver, vcl_synth
1045
1046 The HTTP status message that will be returned.
1047
1048 resp.http.*
1049 Type: HEADER
1050
1051 Readable from: vcl_deliver, vcl_synth
1052
1053 Writable from: vcl_deliver, vcl_synth
1054
1055 Unsetable from: vcl_deliver, vcl_synth
1056
1057 The HTTP headers that will be returned.
1058
1059 See req.http.* for general notes.
1060
1061 resp.do_esi VCL >= 4.1
1062 Type: BOOL
1063
1064 Readable from: vcl_deliver, vcl_synth
1065
1066 Writable from: vcl_deliver, vcl_synth
1067
1068 Default: obj.can_esi
1069
1070 This can be used to selectively disable ESI processing, even though
1071 ESI parsing happened during fetch (see beresp.do_esi). This is use‐
1072 ful when Varnish caches peer with each other.
1073
1074 It is a VCL error to use resp.do_esi after setting resp.filters.
1075
1076 resp.is_streaming
1077 Type: BOOL
1078
1079 Readable from: vcl_deliver, vcl_synth
1080
1081 Returns true when the response will be streamed while being fetched
1082 from the backend.
1083
1084 resp.filters
1085 Type: STRING
1086
1087 Readable from: vcl_deliver, vcl_synth
1088
1089 Writable from: vcl_deliver, vcl_synth
1090
1091 List of VDP filters the resp.body will be pushed through.
1092
1093 Before resp.filters is set, the value read will be the default fil‐
1094 ter list as determined by varnish based on resp.do_esi and request
1095 headers.
1096
1097 After resp.filters is set, changing any of the conditions which oth‐
1098 erwise determine the filter selection will have no effiect. Using
1099 resp.do_esi is an error once resp.filters is set.
1100
1101 Special variables
1102 now
1103 Type: TIME
1104
1105 Readable from: all
1106
1107 The current time, in seconds since the UNIX epoch.
1108
1109 When converted to STRING in expressions it returns a formatted time‐
1110 stamp like Tue, 20 Feb 2018 09:30:31 GMT
1111
1112 sess
1113 A session corresponds to the "conversation" that Varnish has with a
1114 single client connection, over which one or more request/response
1115 transactions may take place. It may comprise the traffic over an HTTP/1
1116 keep-alive connection, or the multiplexed traffic over an HTTP/2 con‐
1117 nection.
1118
1119 sess.xid VCL >= 4.1
1120 Type: STRING
1121
1122 Readable from: client, backend
1123
1124 Unique ID of this session.
1125
1126 sess.timeout_idle
1127 Type: DURATION
1128
1129 Readable from: client
1130
1131 Writable from: client
1132
1133 Idle timeout for this session, defaults to the timeout_idle parame‐
1134 ter, see varnishd(1)
1135
1136 sess.timeout_linger
1137 Type: DURATION
1138
1139 Readable from: client
1140
1141 Writable from: client
1142
1143 Linger timeout for this session, defaults to the timeout_linger pa‐
1144 rameter, see varnishd(1)
1145
1146 sess.send_timeout
1147 Type: DURATION
1148
1149 Readable from: client
1150
1151 Writable from: client
1152
1153 Total timeout for ordinary HTTP1 responses, defaults to the
1154 send_timeout parameter, see varnishd(1)
1155
1156 sess.idle_send_timeout
1157 Type: DURATION
1158
1159 Readable from: client
1160
1161 Writable from: client
1162
1163 Send timeout for individual pieces of data on client connections,
1164 defaults to the idle_send_timeout parameter, see varnishd(1)
1165
1166 storage
1167 storage.<name>.free_space
1168 Type: BYTES
1169
1170 Readable from: client, backend
1171
1172 Free space available in the named stevedore. Only available for the
1173 malloc stevedore.
1174
1175 storage.<name>.used_space
1176 Type: BYTES
1177
1178 Readable from: client, backend
1179
1180 Used space in the named stevedore. Only available for the malloc
1181 stevedore.
1182
1183 storage.<name>.happy
1184 Type: BOOL
1185
1186 Readable from: client, backend
1187
1188 Health status for the named stevedore. Not available in any of the
1189 current stevedores.
1190
1191 HTTP response status
1192 A HTTP status code has 3 digits XYZ where X must be between 1 and 5 in‐
1193 cluded. Since it is not uncommon to see HTTP clients or servers rely‐
1194 ing on non-standard or even invalid status codes, Varnish can work with
1195 any status between 100 and 999.
1196
1197 Within VCL code it is even possible to use status codes in the form
1198 VWXYZ as long as the overall value is lower than 65536, but only the
1199 XYZ part will be sent to the client, by which time the X must also have
1200 become non-zero.
1201
1202 The VWXYZ form of status codes can be communicate extra information in
1203 resp.status and beresp.status to return(synth(...)) and return(er‐
1204 ror(...)), to indicate which synthetic content to produce:
1205
1206 sub vcl_recv {
1207 if ([...]) {
1208 return synth(12404);
1209 }
1210 }
1211
1212 sub vcl_synth {
1213 if (resp.status == 12404) {
1214 [...] // this specific 404
1215 } else if (resp.status % 1000 == 404) {
1216 [...] // all other 404's
1217 }
1218 }
1219
1220 The obj.status variable will inherit the VWXYZ form, but in a ban ex‐
1221 presion only the XYZ part will be available. The VWXYZ form is strictly
1222 limited to VCL execution.
1223
1224 Assigning an HTTP standardized code to resp.status or beresp.status
1225 will also set resp.reason or beresp.reason to the corresponding status
1226 message.
1227
1229 • varnishd(1)
1230
1231 • vcl(7)
1232
1234 VCL was developed by Poul-Henning Kamp in cooperation with Verdens Gang
1235 AS, Redpill Linpro and Varnish Software. This manual page is written
1236 by Per Buer, Poul-Henning Kamp, Martin Blix Grydeland, Kristian Lyn‐
1237 gstøl, Lasse Karstensen and others.
1238
1240 This document is licensed under the same license as Varnish itself. See
1241 LICENSE for details.
1242
1243 • Copyright (c) 2006 Verdens Gang AS
1244
1245 • Copyright (c) 2006-2021 Varnish Software AS
1246
1247
1248
1249
1250 VCL-VARIABLES(7)