I have a payment page and when the user submits, it captures the payment and directs to a thank you page. The problem is that when the user clicks back, the browser takes them back to the previously submitted page with the payment form and all.
How can i prevent the user from accessing the previous page?
Thanks
@James, put this method in your application controller and call this method on before_action callback like -
before_action :set_cache_buster
and then define the action in protected method like ->
To accomplish this we just need to disable browser caching using appropriate HTTP headers. Here’s the secret:
Cache-Control: no-cache, max-age=0, must-revalidate, no-store
Taken individually, each of these Cache-Control attributes would seem to prevent caching. In practice, no-cache and no-store are usually interchangeable in most browsers. However for the back button cache specifically, Firefox will only disable this cache if no-store is specified. To play it safe and guarantee cross-browser compatibility, you should use all four attributes.
For more info see the link - Difference between Pragma and Cache-control headers?
Hope you enjoy this.
For specific page ->
1) Add that callback on specific page with only option like ->
before_action :set_cache_buster, only: [:your_action_name]