Prashanth
Prashanth

Reputation: 11

inline C & vcl caching

I have the url

...../suggest?callback=jsonp9999999999999&term=something

I would like to strip out callback=jsonp999999999999& from the url, cache the rest (...../suggest?term=something) and pass the complete URL (...../suggest?callback=jsonp9999999999998&term=something) again to the backend.

When a second request comes of the format (...../suggest?callback=jsonp000000000000&term=something) varnish must strip out callback=jsonp000000000000& check the cache for a hit and return the result from the cache.

Is this possible with inline C and VCL?

Upvotes: 0

Views: 288

Answers (2)

Mojah
Mojah

Reputation: 1373

It's possible, you can alter the req.url parameters just like you would manipulate cookies or other headers. Here's an example of how to strip out the Google Analytics parametes before they are sent to your backend, the same logic applies here.

Upvotes: 1

Some programmer dude
Some programmer dude

Reputation: 409384

If the query string always starts with "callback=jsonp" then search for the beginning of that (strstr is good for that). Then just find the next '&' (strchr is the function to use here). Then copy the first part to a new buffer, and concatenate the last part to that new buffer.

Upvotes: 1

Related Questions