2

We are using the YII framework, and use the COutputCache for caching the results of a RESTful webservice. RESTful webservices use different HTTP status codes to indicate wether an action was performed successful or not. Unfortunately, HTTP status codes are not saved in the cache.

So when the RESTful webservice returns an error with e.g. status 403 (not authorised), the result data is stored in the cache. The next time the same request is done, the correct output body is taken from the cache, but then it is returned with HTTP status code 200 (success), where it should have returned the same 403.

There are two ways to solve this issue:

  1. Do not store any data in the cache with a status code other than 200
  2. Store the http status code in the cache and use it to set the correct status code when the content comes from the cache

Preferrably, we would go for the second option. The first option could be a (temporary) workaround.

We are struggling to get both of these options to work. How should we extend the COutputCache to get one of these (preferrably option 2) working?

dbroeks
  • 180
  • 1
  • 9

1 Answers1

0

I would use data caching. With this you can decide for option 1 or 2. Personally I would prefer option 1 because sometimes you can get a temporary server error (500) or something. You should not cache the result of a temporary error.

Tim
  • 929
  • 1
  • 14
  • 28