1

Is it possible to have the faraday-http-cache middleware return a cached resource when the origin is down, sort of like what Cloudflare does? I ask because our Rails application is currently doubling as a sort of shared cache for our CMS's REST API and we would like to serve cached content if the CMS goes down.

There was a hack for this posted in a GitHub issue from 2016. The conversation suggests the use of the max-stale cache directive because there were no concrete plans to implement the stale-if-error directive from RFC 5861. Does anyone know for sure if this still works?

Thanks.

Community
  • 1
  • 1
jajavoli
  • 63
  • 2
  • 7

1 Answers1

0

After running some tests, it appears that if the origin domain is non-existent then you will just get a network error, even if dummy data for the fake site is stored in the cache. I had to implement new middleware for recovering from these errors.

jajavoli
  • 63
  • 2
  • 7