Rail API - Disable cached response

98 Views Asked by At

I have a Rails 6 API-only application and I'm using Nginx and passenger.

When I try to do GET or POST in the Postman application or other places, I get only cached responses.

For instance, if I try to get user 1, movies, I'll get the correct ones, but if I change the JWT to user 2, I still see the previous response which was for user 1.

I have tried a few options such as:

In production.rb I added:

config.action_controller.perform_caching = false
config.cache_store = :null_store

I have also tried the controller level by adding: expires_now which in the header shows no-cache and also with expires_in 5.seconds, public: false which shows max-age=5, private as the header, but I still get the same response for any user.

1

There are 1 best solutions below

0
On

you can use a command to disable cache in rails app: rails dev:cache