Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Varnish: Misc

How to ignore chars after question mark in URL?

 

 

Varnish misc RSS feed   Index | Next | Previous | View Threaded


listas at kurtkraut

Apr 3, 2012, 7:25 AM

Post #1 of 3 (474 views)
Permalink
How to ignore chars after question mark in URL?

Hi,


I need to cache URLs of the same file but the front-end developer generates
a random string, e.g.:

www.kurtkraut.net/index.css?234234432
www.kurtkraut.net/index.css?654323256
www.kurtkraut.net/index.css?905837831

How can I get a HIT for www.kurtkraut.net/index.css not matter the presence
or not of the question mark and the random string after the question mark?
Is it possible to ignore the presence of the question mark and the rest of
the URL?


Thanks in advance,


Kurt Kraut


r at roze

Apr 3, 2012, 7:38 AM

Post #2 of 3 (459 views)
Permalink
Re: How to ignore chars after question mark in URL? [In reply to]

> Is it possible to ignore the presence of the question mark and the rest of the URL?

Yes.
https://www.varnish-cache.org/docs/trunk/faq/general.html

'How do I instruct varnish to ignore the query parameters and only cache one instance of an object?'

sub vcl_recv {
set req.url = regsub(req.url, "\?.*", "");
}

_______________________________________________
varnish-misc mailing list
varnish-misc [at] varnish-cache
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


contact at jpluscplusm

Apr 3, 2012, 10:39 AM

Post #3 of 3 (456 views)
Permalink
Re: How to ignore chars after question mark in URL? [In reply to]

On 3 April 2012 15:25, Kurt Kraut <listas [at] kurtkraut> wrote:
> Hi,
>
> I need to cache URLs of the same file but the front-end developer generates
> a random string, e.g.:
>
> www.kurtkraut.net/index.css?234234432
> www.kurtkraut.net/index.css?654323256
> www.kurtkraut.net/index.css?905837831
>
> How can I get a HIT for www.kurtkraut.net/index.css not matter the presence
> or not of the question mark and the random string after the question mark?
> Is it possible to ignore the presence of the question mark and the rest of
> the URL?

In my experience, developers often do this deliberately as a method of
versioning their CSS and JS. They'll append a "random" string (often a
unix timestamp) at deployment time, rendering that particular version
of the resource cachable until the next deployment.

Are you absolutely sure that this isn't what your devs are doing?
Because if they are, you'd be doing *exactly* the wrong thing by
explicitly ignoring the query-string, and may well break the
application during a random deploy, sometime in the future. But
possibly not during *each* deployment, leading to nicely intermittent
bug reports depending on the amount each CSS/JS has changed, and the
state of the user's browser cache :-)

HTH,
Jonathan
--
Jonathan Matthews
London, Oxford, UK
http://www.jpluscplusm.com/contact.html

_______________________________________________
varnish-misc mailing list
varnish-misc [at] varnish-cache
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

Varnish misc RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.