Increase Your Hit Ratio With This Simple Tip

If you're caching URLs that include user input, such as a search box, and the search is case insensitive, there's a really easy way to increase your hit ratio: convert the URL to lowercase.

# at the top of your VCL
import std;

...

sub vcl_recv {
  if (req.url ~ "^/search\?") {
    set req.url = std.tolower(req.url);
  }
  ...
}

There are so many different ways to type the same word. People using a PC will often not use caps at all, and people using phones and tablets will sometimes type in all caps — or if they have smart keyboards, their text will usually have a capital letter at the beginning of the phrase or sentence. That's three different URLs and thus three requests to your origin, where the results are exactly the same. With std.tolower(), you'll only get one request to origin.

that is really insensitive
Rogier Mulhuijzen
Senior Professional Services Engineer
Published

1 min read

Want to continue the conversation?
Schedule time with an expert
Share this post
Rogier Mulhuijzen
Senior Professional Services Engineer

Rogier “Doc” Mulhuijzen is a senior professional services engineer and Varnish wizard at Fastly, where performance tuning and troubleshooting have formed the foundation of his 18-year career. When he’s not helping customers, he sits on the Varnish Governance Board, where he helps give direction and solve issues for the Varnish open source project. In his spare time, he likes to conquer all terrains by riding motorcycles, snowboarding, and sailing.

Ready to get started?

Get in touch or create an account.