When should HTML Cache be enabled in Sitecore using "By Query String"? I believe one case would be search. Even in that case, on which component should it ideally be enabled?

3 Answers 3


In Sitecore, the HTML cache is used to cache renderings/content (or pieces of the page), not the whole pages, and normally HTML cache is useful to improve the performance of the websites.

enter image description here

Cacheable - It basically says to Sitecore that this component should be cached - to use caching you need to enable this. This option should be enabled for the Vary by options to work. With only this setting enabled Sitecore will create a cache for the rendering and will use it to show same content every time that the component is used across all pages.

Vary by Query String - Selecting this Sitecore will cache different pieces for each query string that you have. So if you have a page that renders based on the query string for example the Search Page, can use that if you search text, the results page, and selected filters as a query string.

Reference link for brief details - https://konabos.com/blog/sitecore-10-1-cache-strategies

Hope it helps!


In Sitecore, you would enable HTML caching on a component by setting its property to cacheable. This would cache the first ever rendering of the component, then serve that HTML every time you decide to output that component on a page. This is good for content that does not change across the full site (often footer for example).

In addition to the above, if you set Vary by Query String, then a new cache of that component would be created for every unique query string. If the same query string was to occur then the cached version would be servered instead of rendered fresh.

Search might be a good option for using vary by query string, but this would depend entirely on your implementation. If for example, it is implemented fully using GET commands, and the search parameters are pushedinto the query string, then it would make sense to vary by query string.

In short, if there is no other possible desired rendering for your component, when the query string is the same then use it. If however, you might want a different rendering for a different device or if certain parameters are chosen for the component on different pages, then consider using those options too.

  • Thanks for the detailed explanation Commented Feb 14, 2023 at 5:30

The VaryByQueryString property controls whether or not output caching varies based on query string parameters passed in the URL. The VaryByParm property causes output caching to vary based on rendering parameter values passed by the developer. The VaryByQueryString property causes output caching to vary based on parameters passed in the URL query string.

Developers set the VaryByQueryString property

  • To True for components that generate different output when supplied different query string parameters.
  • To False for components that do not generate different output when supplied different query string parameters.

The cache key is: controller::[Controller]#[Controller Action]#lang:[Language Culture Code]#qs:[request.QueryString] By adding the current request query string to the key we can different cached rendering based on the query string values.

  • Thanks for the detailed explanation Commented Feb 14, 2023 at 5:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.