title: How to Cache Multiple Versions of a Page using Razor Dynamic Query & WebCache
body: <p>I decided to implement caching to improve the performance of the product pages.</p>
  
  <p>Each page contains a large amount of the product's images.</p>
  
  <p>I created the following code in a Razor view.</p>
  
  <pre><code>@{   
  var productID = UrlData[0].AsInt();
  var cacheItemKey = "products"; 
  var cacheHit = true; 
  var data = WebCache.Get(cacheItemKey);
  
  var db = Database.Open("adldb");
  if (data == null) { 
  cacheHit = false; 
  } 
  if (cacheHit == false) {   
  data = db.Query("SELECT * FROM Products WHERE ProductID = @0", productID).ToList();
  WebCache.Set(cacheItemKey, data, 1, false);
  }
  }
  </code></pre>
  
  <p>I'm using the data with the following code:</p>
  
  <pre><code>@foreach (dynamic p in data)
  {
  &lt;a href="~/Products/View/@p.ProductID"
  &lt;img src="~/Thumbnail/@p.ProductID"&gt;&lt;/a&gt;
  }
  </code></pre>
  
  <p>The caching code works well, but when passing the new query string parameter (changing the version of the page) the result in browser is the same for the declared cashing time.</p>
  
  <p>How to make caching every version of the page?</p>
  
  <p>Thanks</p>
  
  <p>Oleg</p>