I have a WP site with managed hosting that uses Varnish. I have a landing page that displays the appropriate images based on a couple arguments passed through the query string. So for example, depending on where the user is requesting this page from, the URL might be
www.example.com/landing?v=2... and each of those pages would contain a different logo image that is determined by the value of
v in the query string.
It seems that the default behavior for Varnish is to serve the cached version of the page and ignore (or maybe strip) any query string parameters. As a result, both of the URLs above display the same exact page (using the default image coded into the page), which is not correct for either.
<?php $logoBase = 'path/to/logo-'; $logoSrc = isset($_GET['v']) ? $logoBase . $_GET['v'] : 'default'; $logoSrc .= '.svg'; ?> <img src="<?php echo $logoSrc ?>" alt="logo">
With that, a couple questions:
Ideally I'd like to use the cached version of that page and still display the logo dynamically, but something tells me that's not possible. Is it? If so, is there some configuration file that will tell Varnish to do just that rather than rendering it 100% from the cached version as if there was no query string?
If that is not possible, is there a way to specify that a page is not to be served from the cache and to render it dynamically, fresh from scratch on each request while still serving all other pages from the cache?
And what about Google Analytics UTM parameters? Even though it doesn't affect how the page displays, having those parameters ignored is very problematic. How is that typically handled?
Unless there is a very simple config answer, I'm not asking for any code. I just need a starting point (advice on WP best practice as it pertains too caching and dynamic content) so I can figure out what I can configure myself (and what should be configured differently) and what I'll need to ask the hosting admins to modify.