This is a sample Varnish 4.1-style VCL for using Varnish to cache JSONP requests, where the approach is drawn wholesale from the approach outlined by this great Fastly post.
I've made a few changes from Fastly's example:
- the VCL functions and syntax have been updated to reflect Varnish 4.1 syntax
- this also sanitizes the "_" parameter, which jQuery will sometimes also add when you use the
$.ajax
convenience method - some regexes have been modified based on testing
It doesn't do anything to specifically make a given request cache-able (e.g. you'd need to add any logic to sanitize cookies, or modify cache TTL's, etc.)