caching solutions with varnish
DESCRIPTION
Caching solutions with Varnish - presentation held by Bogdan Hadadea at Open Coffee Tech meetupTRANSCRIPT
![Page 1: Caching solutions with Varnish](https://reader036.vdocument.in/reader036/viewer/2022082805/54b7aa904a79590e468b458b/html5/thumbnails/1.jpg)
Caching Solutions:Varnish
with Bogdan Hadadea
![Page 2: Caching solutions with Varnish](https://reader036.vdocument.in/reader036/viewer/2022082805/54b7aa904a79590e468b458b/html5/thumbnails/2.jpg)
1. General Description: Varnish
• HTTP Accelerator• Caching reverse proxy
o Sits in front of any HTTP server
• Load Balancer• Fail Over System• Perfect Browser caching solution
o Prevents hard refresh calls
• Typical speedup: 300x-1000x• VCL – compiled to C• ESI
![Page 3: Caching solutions with Varnish](https://reader036.vdocument.in/reader036/viewer/2022082805/54b7aa904a79590e468b458b/html5/thumbnails/3.jpg)
1. General Description: Varnish
ESI – Edge Side Includes• Allows page fragmentation• Fragments with different TTL• ESI are serialized• Configurable depth of ESI calls• Doesn’t support alt and noerror attributes• ESI calls can’t set cookies
![Page 4: Caching solutions with Varnish](https://reader036.vdocument.in/reader036/viewer/2022082805/54b7aa904a79590e468b458b/html5/thumbnails/4.jpg)
2. Usage: Varnish
• Originally built for Norwegian newspaper• Current users:
o Facebooko Twittero Huluo BBCo Wired
![Page 5: Caching solutions with Varnish](https://reader036.vdocument.in/reader036/viewer/2022082805/54b7aa904a79590e468b458b/html5/thumbnails/5.jpg)
3. Architecture: Varnish - Overview
![Page 6: Caching solutions with Varnish](https://reader036.vdocument.in/reader036/viewer/2022082805/54b7aa904a79590e468b458b/html5/thumbnails/6.jpg)
3. Architecture: Varnish
Main methods:
• vcl_recv – beginning of request• vcl_fetch – after response from backend• vcl_hash – how to create a hash key• vcl_deliver – before a cached object is delivered• vcl_error – when there is an error
![Page 7: Caching solutions with Varnish](https://reader036.vdocument.in/reader036/viewer/2022082805/54b7aa904a79590e468b458b/html5/thumbnails/7.jpg)
3. Architecture: Varnish
VCL_RECV:
• Manipulate/remove cookies• Manipulate/add/remove headers• Request standardization• Cache bypassing
![Page 8: Caching solutions with Varnish](https://reader036.vdocument.in/reader036/viewer/2022082805/54b7aa904a79590e468b458b/html5/thumbnails/8.jpg)
3. Architecture: Varnish
VCL_FETCH
• Enable ESI• Manipulate headers• Manipulate cookies• Vary• Set/manipulate cache times
![Page 9: Caching solutions with Varnish](https://reader036.vdocument.in/reader036/viewer/2022082805/54b7aa904a79590e468b458b/html5/thumbnails/9.jpg)
4. Comparison: Squid
Advantages of Squid over Varnish:• Built in SSL support• Better support for streaming delivery of objects• Support for antivirus plugins
Advantages of Varnish over Squid:• Amazing configuration system – VCL• Better performance and scalability• Better invalidation support• Better module support
![Page 10: Caching solutions with Varnish](https://reader036.vdocument.in/reader036/viewer/2022082805/54b7aa904a79590e468b458b/html5/thumbnails/10.jpg)
5. Conclusion
• Simple and great performance increase• VCL is powerful but sometimes simple is better• Make sure you can still handle a cold start