Railgun support with Cache Everything Page Rule

railgun

#1

Currently, if Cache level is set to “Cache Everything” via Page Rules for particular resources, then Railgun doesn’t work when the cached version of the resource is not present in the CloudFlare’s edge location (aka when requests need to go to the origin server to get that resource) even when Railgun is supported for that domain.

Is it possible somehow to make Cache Everything and Railgun work together for the same resource so that when trip back to the origin server is required (when cache is not present at edge location) then that request to the origin server is accelerated by Railgun


#2

Hi there,

Railgun is designed to optimise resources that cannot be cached (dynamic content) which is why this does not work with cached content. Cached requests are also served by cloudflare’s edge server which means your origin is never contacted which is where your railgun instance is used.

The reason this does not work with a cache miss is because the first request made to your origin for a new resource will always be made direct as this first request will establish the railgun connection between our sender and listener. Subsequent requests will then be made through railgun once the connection has been established between sender and listener.

At this point however Cloudflare will have cached the resource on our edge as the first request for this resource will have populated our cache, subsequent requests will then be returned from our edge (cached) until the resource expires.

More information on how railgun establishes connections and how to interpret the cf-railgun headers can be found in the article below.

Hope this helps!,

Scott