Table of Contents for
Getting Started with Varnish Cache
Close
Version ebook
/
Retour
Getting Started with Varnish Cache
by Thijs Feryn
Published by O'Reilly Media, Inc., 2017
nav
Cover
Varnish
Getting Started with Varnish Cache
Getting Started with Varnish Cache
Dedication
Preface
1. What Is Varnish Cache?
2. Go, Go, Go and Get Started!
3. Varnish Speaks HTTP
4. The Varnish Configuration Language
5. Invalidating the Cache
6. Dealing with Backends
7. Improving Your Hit Rate
8. Logging, Measuring, and Debugging
9. What Does This Mean for Your Business?
10. Taking It to the Next Level
Index
About the Author
Colophon
Preface
Conventions Used in This Book
O’Reilly Safari
How to Contact Us
Acknowledgments
1. What Is Varnish Cache?
Why Does Web Performance Matter?
Where Does Varnish Fit In?
The Varnish Cache Open Source Project
How Does Varnish Work?
Caching Is Not a Trick
Conclusion
2. Go, Go, Go and Get Started!
Installing Varnish
Installing Varnish Using a Package Manager
Installing Varnish on Ubuntu and Debian
Installing Varnish on Red Hat and CentOS
Configuring Varnish
The Configuration File
Some Remarks on Systemd on Ubuntu and Debian
Startup Options
What About TLS/SSL?
Conclusion
3. Varnish Speaks HTTP
Idempotence
State
Expiration
The Expires Header
The Cache-Control Header
Expiration Precedence
Conditional Requests
ETag
Last-Modified
How Varnish Deals with Conditional Requests
Cache Variations
Varnish Built-In VCL Behavior
When Is a Request Considered Cacheable?
When Does Varnish Completely Bypass the Cache?
How Does Varnish Identify an Object?
When Does Varnish Cache an Object?
What Happens if an Object Is Not Stored in Cache?
How Long Does Varnish Cache an Object?
Conclusion
4. The Varnish Configuration Language
Hooks and Subroutines
Client-Side Subroutines
Backend Subroutines
Initialization and Cleanup Subroutines
Custom Subroutines
Return Statements
The execution flow
VCL Syntax
Operators
Conditionals
Comments
Scalar Values
Regular Expressions
Functions
Includes
Importing Varnish Modules
Backends and Health Probes
Access Control Lists
VCL Variables
Varnish’s Built-In VCL
A Real-World VCL File
Conclusion
5. Invalidating the Cache
Caching for Too Long
Purging
Banning
Lurker-Friendly Bans
More Flexibility
Viewing the Ban List
Banning from the Command Line
Forcing a Cache Miss
Cache Invalidation Is Hard
Conclusion
6. Dealing with Backends
Backend Selection
Backend Health
Directors
The Round-Robin Director
The Random Director
The Hash Director
The Fallback Director
Grace Mode
Enabling Grace Mode
Conclusion
7. Improving Your Hit Rate
Common Mistakes
Not Knowing What Hit-for-Pass Is
Returning Too Soon
Purging Without Purge Logic
No-Purge ACL
404 Responses Get Cached
Setting an Age Header
Max-age Versus s-maxage
Adding Basic Authentication for Acceptance Environments
Session Cookies Everywhere
No Cache Variations
Do You Really Want to Cache Static Assets?
URL Blacklists and Whitelists
Decide What Gets Cached with Cache-Control Headers
There Will Always Be Cookies
Admin Panel
Remove Tracking Cookies
Remove All But Some
Cookie Variations
Sanitizing
Removing the Port
Query String Sorting
Removing Google Analytics URL Parameters
Removing the URL Hash
Removing the Trailing Question Mark
Hit/Miss Marker
Caching Blocks
AJAX
Edge Side Includes
Making Varnish Parse ESI
ESI versus AJAX
Making Your Code Block-Cache Ready
An All-in-One Code Example
Conclusion
8. Logging, Measuring, and Debugging
Varnishstat
Example Output
Displaying Specific Metrics
Output Formatting
Varnishlog
Example Output
Filtering the Output
Varnishtop
Conclusion
9. What Does This Mean for Your Business?
To CDN or Not to CDN
VCL Is Cheaper
Varnish as a Building Block
The Original Customer Case
Varnish Plus
Companies Using Varnish Today
NU.nl: Investing Early Pays Off
SFR: Build Your Own CDN
Varnish at Wikipedia
Combell: Varnish on Shared Hosting
Conclusion
10. Taking It to the Next Level
What About RESTful Services?
Patch Support
Authentication
Invalidation
Extending Varnish’s Behavior with VMODs
Finding and Installing VMODs
Enabling VMODs
VMODs That Are Shipped with Varnish
Need Help?
The Future of the Varnish Project
Index