Unset before variable set


Reading the guide for Delivering different content to different devices, I noticed that the suggested VCL does the following:

  unset req.http.X-UA-Device;
  unset req.http.X-UA-Vendor;

  set req.http.X-UA-Device = "desktop";
  set req.http.X-UA-Vendor = "generic";

What is the purpose of using unset before set?


To zero out any aberrant values. Also, if there’s shielding involved, you may not want the header twice.


Thanks for your answer, Peter! Didn’t know you could have a header twice!

Wouldn’t set zero out any aberrant values by overwriting a new value?


If you have shielding set up, VCL will run at both the edge POP as well as the shield POP. and yeah… the unsetting really does fall into the ‘paranoia’ category, as you are correct…the value would be overwritten :slight_smile:


Got it! Thanks again, Peter.