Extend Fastly to vary its caching per user-agent: BingBot and GoogleBot and the rest.

Comments

2 comments

  • Hiromasa Kakehashi

    Hi Gulshan,

    I don't see any issues in Varying on a custom header as you do in the code.
    You just need to set the Vary header in the responses. Here is an example:

    vcl_recv

    if ( req.http.User-Agent ~ "(?i)PATTERN1" ) {
    set req.http.X-UA-Device = "Bot";
    } else if ( req.http.User-Agent ~ "(?i)PATTERN2" ) {
    set req.http.X-UA-Device = "Mobile";
    } else {
    set req.http.X-UA-Device = "Desktop";
    }

    vcl_fetch

    if (beresp.http.Vary) {
    set beresp.http.Vary = beresp.http.Vary "X-UA-Device";
    } else {
    set beresp.http.Vary = "X-UA-Device";
    }
    0
    Comment actions Permalink
  • Gulshan Beejan

    Hi Hiromasa,

     

    Thanks for your reply. We already have a vcl fetch implemented as per your recommendation. I'll apply these on and see how it goes.

     

    Appreciate your help!

    0
    Comment actions Permalink

Please sign in to leave a comment.