Reputation: 23989
I have a site where items are loaded onto a page in the DOM as I'm using a masonry type effect.
Now, users can delete these items at any time, many at once if they choose to.
The problem is, after deleting, I refresh the page showing the items by reloading it, and the items are still there. Even if I leave the page and return the items are still there. But they have definitely beeen removed from the db table. The only way to clear them from the page is CTRL+R, a complete refresh
How can I clear the DOM cache, or force a refresh? Or is there a better way to do this?
I'm using PHP as main backend lanuguage. I'm also using Jquery.
Not sure what to tag this but think JS and Jquery issue so will start with that.
Upvotes: 1
Views: 1090
Reputation: 23989
Added timestamp to ajax call so it doesn't cache in the first place, simple really when you think about it backwards!
Many thanks for the other answer/comment
Upvotes: 0
Reputation: 1074475
It's neither a JavaScript nor jQuery issue. It's a caching issue. You need to configure your web server to set the correct cache control headers (Expires
and similar) so the browser knows to re-fetch the page. (You can also set them in the PHP response if you need to vary them from page to page by using the header
function.)
I won't single out a specific link, but if you search for "cache control" you'll find a million tutorials. :-)
Upvotes: 1