Unset before variable set


#1

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?


#2

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


#3

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?


#4

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:


#5

Got it! Thanks again, Peter.