Volver al blog

Síguenos y suscríbete

Sólo disponible en inglés

Por el momento, esta página solo está disponible en inglés. Lamentamos las molestias. Vuelva a visitar esta página más tarde.

Increase Your Hit Ratio With This Simple Tip

Rogier Mulhuijzen

Senior Professional Services Engineer

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.