/    Sign up×
Community /Pin to ProfileBookmark

AJAX has cache?

I have a script that loads my content in a div using AJAX. I use this for various(and obvious) reasons.

Well, if I load some content, then it changes(while the user still has the page up), if they click on the link to reload that same page of content, it is not really refreshed. The same content that was there before is still there.

The only way I know to solve the problem is use the browsers refresh button, and refresh the actual webpage. Then when you use the link the AJAX script gets the content and loads it, with the changes(since it gets the file at that exact time, thus getting the newer version).

It is almost like AJAX is using some type of cache so when I get content, it remembers it, and then if I try to get that same content again(even after loading different content), it will load the old version of the content, just like it did the first time.

I doubt it is the browsers fault, since the new content can be loaded once the page is refreshed. The browser wouldn’t keep the information and then delete it once the page is refreshed, would it?

It seems to be like this for IE and Firefox.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@Sup3rkirbyauthorSep 06.2007 — Actually, don't throw out the who browser cache thing...


I think just IE is doing it. If I change a page, IE won't reload the new data until I open it up seperately(via my cPanel for my site).

So basically I change a file. Then whatever I load with AJAX is kept, and the site will keep loading that same content until I go into my cPanel and open up the content file there. Then it seems the cache is changed and the site now loads that page.

[COLOR="Red"][EDIT][/COLOR]

Confirmed!

It is some IE problem it seems. Actually, now in Firefox when I change the content(using PHP and AJAX), the browser will load the new changes right away(and hopefully it will do this all the time now because it didn't used to do this).

For some reason I will have to close the tab in IE(or window for older IE versions) and then reopen the page again(completely reloading the page in memory). Then and only then will it load the newly changed content.
×

Success!

Help @Sup3rkirby spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...