How can I force [removed] to make an HTTP request instead of using the cache?

后端 未结 5 1722
难免孤独
难免孤独 2021-01-11 17:18

In my web application I am setting window.location to navigate to a different page, but for some reason Firefox shows an old version of that page.

Usin

5条回答
  •  天涯浪人
    2021-01-11 18:13

    just need to tell your download function (in the controller, in case of Laravel) do not cache it by setting the headers, used the following code for Laravel:

    $headers =[
                'Content-Type' => 'application/text',
                'Cache-Control' => 'no-store, no-cache, must-revalidate, max-age=0',
                'Cache-Control' => 'post-check=0, pre-check=0, false',
                 'Pragma' => 'no-cache',  ];
    return response()->file($pathToFile, $headers);
    

    This code is very much true for PhP as well just need transferring the code accordingly. By adding new dates may invalidate a link especially if you are using a temporarySignedLink etc.

    Cheers

提交回复
热议问题