ブログに戻る

フォロー&ご登録

英語のみで利用可能

このページは現在英語でのみ閲覧可能です。ご不便をおかけして申し訳ございませんが、しばらくしてからこのページに戻ってください。

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.