Skip to content

Prevent custom url parameter in Product Page to be Cached

I am working on a requirement to add a custom parameter in the configurable product page URL. This will have the simple SKU to preselect the color in the swatches, something like this:

https://site.test.com/product-page-url.html?v=simplesku

The user requires this way because these URLs will be generated by the marketing team and need an easy way to create a URL to each simple and send in the marketing communication (for example, newsletter or Facebook posts).

The customization works fine, and it selects the simple product in the swatches specified in the URL without a problem. However, this selection seems to be caching. So, for example, if you first go to this URL:

https://site.test.com/product-page-url.html?v=simplesku

It shows the correct color. But if you next go to:

https://site.test.com/product-page-url.html?v=simplesku2

https://site.test.com/product-page-url.html?v=simplesku3

https://site.test.com/product-page-url.html?v=simplesku4

Or even without the parameter in the URL:

https://site.test.com/product-page-url.html

The result is the same. The page shows the first color and ignores the parameter in all the subsequent attempts. Is it a way to add this custom parameter to prevent to be caching, and with that, each URL with a different value in it generates a different page result?