Nasim
Nasim

Reputation: 105

PHP Redirect that force refresh (CTRL+F5)

I have a page with an editable table. I need users to be able to edit this and then submit their changes. Everything works well until I redirect them to the same page with new content (relevant to their changes). However, they see the old content.

If I press ctrl+f5 on the browser, they content gets updated. I was wondering if there is a way to force this. This is my php code which does not help force refreshing:

header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Pragma: no-cache');
header( 'Location: http://www.bamozir.com/en/mtl-en/recent/general-info/cost#edit' );

Eugen Rieck Solution works perfect for firefox, chrome, and safari. But not on IE and Opera. Any idea how to fix this?

Upvotes: 3

Views: 13575

Answers (3)

Eugen Rieck
Eugen Rieck

Reputation: 65342

What ALLWAYS works: Assuming your URL is http://my.server/my/page?a=b&c=d you redirect to http://my.server/my/page?a=b&c=d&nocache=1234567890 with 1234567890 being a large random number

Upvotes: 3

rzetterberg
rzetterberg

Reputation: 10268

Use this header to use refresh:

Refresh: 0;url=http://www.bamozir.com/en/mtl-en/recent/general-info/cost#edit

See more on that topic here: 'Refresh' HTTP header

Upvotes: 2

Mattygabe
Mattygabe

Reputation: 1790

You must set the cache control and expiration on the page which you wish to force-refresh on. By setting that before the redirect, you're telling the browser to not cache the page you're redirecting from.

Upvotes: 2

Related Questions