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.
Asked
Active
Viewed 197 times
-5
-
4Use AJAX. With such a vague question, you can't expect a more detailed answer. – Barmar May 18 '13 at 09:28
-
I think what you are looking for is Asynchronous JavaScript and XML (AJAX) - have a look at google how it can help you. – DominikAngerer May 18 '13 at 09:29
3 Answers
-1
you should try this:
Use Category: Shorthand Methods: AJAX ajax

Jignesh.Raj
- 5,776
- 4
- 27
- 56
-
"want to reload page only once when start." This will refresh the page not only once when start – DominikAngerer May 18 '13 at 09:33
-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.
-2
Change your code to
window.location='post_info.php?post_id='+postid+"&"+ new Date().getTime();

Xinus
- 29,617
- 32
- 119
- 165