I understand that this is an old question, but the same problem just caught me, so I decided that I would write the answer anyway.
In most scenarios, you can invalidate the feedback button cache by connecting the onUnload handler to the window, for example:
window.addEventListener('unload',function(){});
or, if you prefer jQuery:
$(window).unload(function(){});
but since your AJAX response is in JSON, this is obviously not possible, since you cannot include script fragments. In this case, I believe that it is best to set the cache-control: no-store header so that the browser does not try to cache the result.
You can do this in the case of OP with Symfony2 using:
return new Response($res , 200 , array( 'Content-Type' => 'application/json', 'Cache-Control' => 'no-store', ));
or for more general PHP:
header('Cache-Control: no-store');
There is a caveat here that can greatly degrade your performance, depending on the structure of your application, in which case the best option would probably be to just use a different url for your AJAX call. Sucks, I know.
Here you can find bfcache documentation, which may be more useful in different cases.
Jon g
source share