I registered a GET
route for laravel.dev/test
. The corresponding controller for the route would distinguish whether the request is ajax or not.
When I type laravel.dev/test
on the browser, Laravel detect that it's not an ajax request and uses return View::make()
to generate the page. Then Backbone.js
code on the page make an ajax request to laravel.dev/test
and Laravel uses return Response::json
to return a JSON.
It's all fine until when I try to navigate away from the page and then use the browser button to navigate back to laravel.dev/test
that it print out the json as the response, which is not what I expect since I'm not making an ajax request.
Definitely a caching issue. Just to try and get some results, add this to your controller (ajax and non-ajax) to force-disable caching:
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
And see if chrome still fetches from the cache on the back button.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With