Re: Need Assistance in Configuring Varnish to Retain and Ignore Unique Parameter in Request URL while caching

2023-06-05 Thread Guillaume Quintard
Hi, Relevant documentation: - https://varnish-cache.org/docs/trunk/users-guide/vcl-hashing.html - https://www.varnish-software.com/developers/tutorials/varnish-builtin-vcl/ - https://varnish-cache.org/docs/trunk/users-guide/vcl-built-in-code.html Essentially: if you don't use a return statement,

Re: Need Assistance in Configuring Varnish to Retain and Ignore Unique Parameter in Request URL while caching

2023-06-05 Thread Uday Kumar
Hello Guillaume, Thanks for the update! (It's done by default if you don't have a vcl_hash section in your VCL) We can tweak it slightly so that we ignore the whole querystring: sub vcl_hash { hash_data(regsub(req.url, "\?.*","")); if (req.http.host) {

Re: Need Assistance in Configuring Varnish to Retain and Ignore Unique Parameter in Request URL while caching

2023-06-05 Thread Guillaume Quintard
Hi all, Turns out install-vmod works, just needed to grab the right tarballs and have the right dependencies installed. Here's the Dockerfile I used: FROM varnish:7.3 USER root RUN set -e; \ EXTRA_DEPS="autoconf-archive libossp-uuid-dev"; \ apt-get update; \ apt-get -y install

Re: Need Assistance in Configuring Varnish to Retain and Ignore Unique Parameter in Request URL while caching

2023-06-01 Thread Uday Kumar
Thanks for the prompt response! Thanks & Regards Uday Kumar On Thu, Jun 1, 2023 at 11:12 AM Guillaume Quintard < guillaume.quint...@gmail.com> wrote: > Thanks, so, to make things clean you are going to need to use a couple of > vmods, which means being able to compile them first: > -

Re: Need Assistance in Configuring Varnish to Retain and Ignore Unique Parameter in Request URL while caching

2023-06-01 Thread Geoff Simmons
On 6/1/23 03:47, Uday Kumar wrote: Our Requirements: [...] 3. Allowed Characters are Alphanumeric which are *URL safe* [can be lowercase, uppercase in case of alphabets] [...] This time you didn't mention a requirement of exactly 20 characters. If that's not strictly required, it's worth

Re: Need Assistance in Configuring Varnish to Retain and Ignore Unique Parameter in Request URL while caching

2023-05-31 Thread Guillaume Quintard
Thanks, so, to make things clean you are going to need to use a couple of vmods, which means being able to compile them first: - https://github.com/otto-de/libvmod-uuid as Geoff offered - https://github.com/Dridi/libvmod-querystring that will allow easy manipulation of the querystring

Re: Need Assistance in Configuring Varnish to Retain and Ignore Unique Parameter in Request URL while caching

2023-05-31 Thread Geoff Simmons
On 5/31/23 20:06, Uday Kumar wrote: We would like to configure varnish to create unique parameter such that its value should be of 20 characters (alphanumeric characters that are URL safe). I have used VMOD uuid to set unique values in each request: https://github.com/otto-de/libvmod-uuid

Re: Need Assistance in Configuring Varnish to Retain and Ignore Unique Parameter in Request URL while caching

2023-05-31 Thread Guillaume Quintard
Does it need to be unique? can't we just get away with ""? the crude VCL code would look like: set req.url = regsub(req.url, "\?.*","?yourparam="); i.e. getting rid of the whole query string and just putting yours in place. -- Guillaume Quintard On

Re: Need Assistance in Configuring Varnish to Retain and Ignore Unique Parameter in Request URL while caching

2023-05-31 Thread Uday Kumar
Hello, We would like to configure varnish to create unique parameter such that its value should be of 20 characters (alphanumeric characters that are URL safe). On Wed, May 31, 2023, 13:34 Guillaume Quintard wrote: > > Could you please also suggest how to configure Varnish so that Varnish >

Re: Need Assistance in Configuring Varnish to Retain and Ignore Unique Parameter in Request URL while caching

2023-05-31 Thread Guillaume Quintard
> Could you please also suggest how to configure Varnish so that Varnish can add Unique Parameter by itself?? We'd need more context, is there any kind of check that tomcat does on this parameter, does it need to have a specific length, or match a regex? If we know that, we can have Varnish

Re: Need Assistance in Configuring Varnish to Retain and Ignore Unique Parameter in Request URL while caching

2023-05-31 Thread Uday Kumar
Hello Guillaume, Thank you so much for your help, will try modifying vcl_hash as suggested! > Last note: it would probably be better if the tomcat server didn't need > that unique parameter, or at the very least, if Varnish could just add it > itself rather than relying on client information as

Re: Need Assistance in Configuring Varnish to Retain and Ignore Unique Parameter in Request URL while caching

2023-05-30 Thread Guillaume Quintard
Hi Uday, Ultimately, you'll probably want to learn and use this vmod: https://github.com/Dridi/libvmod-querystring , but in the meantime, we can use a quick hack. Essentially, we don't need to modify the URL, but we can just alter the cache key computation. By default, the key logic looks like

Need Assistance in Configuring Varnish to Retain and Ignore Unique Parameter in Request URL while caching

2023-05-30 Thread Uday Kumar
Hello everyone, In our system, we're currently using Varnish Cache in front of our Tomcat Server for caching content. As part of our new requirement, we've started passing a unique parameter with every URL. The addition of this unique parameter in each request is causing a cache miss, as Varnish