-5

I'm making kind of social website. And i make a post edit page. The problem is when i finish edit post and click 'SAVE EDIT'. i use window.location='post_info.php?post_id='+postid; on AJAX to go back to post info page. But it appear to be old content from cache. question is what should i do to make my new post info appear immediatly when open it.

Xinus
  • 29,617
  • 32
  • 119
  • 165
Expl0de
  • 647
  • 1
  • 8
  • 23

3 Answers3

-1

you should try this:

Use Category: Shorthand Methods: AJAX ajax

Jignesh.Raj
  • 5,776
  • 4
  • 27
  • 56
-1

You just need to set the cache control HTTP headers for your HTML document so that the document is always loaded from the server and not the browser (or proxy) cache.

You can't do this with JavaScript or HTML (meta http-equiv is a joke), you need to set real HTTP headers.

Either

Cache-Control: max-age=0

or

Cache-Control: no-cache

should get you what you want. See this answer for an explanation of the differences between them and Mnot's caching tutorial for a more in depth look at caching and HTTP.

You can set these with a server side programming language (e.g. Perl, Python or PHP) or by configuring the web server directly. The specifics depend on which of those you choose.

Community
  • 1
  • 1
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
-2

Change your code to

window.location='post_info.php?post_id='+postid+"&"+ new Date().getTime();
Xinus
  • 29,617
  • 32
  • 119
  • 165