Call usTry Fastly free

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

Want to continue the conversation?Schedule time with an expert
Share this post