Clear the user's cache

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Pavilion
Forum Contributor
Posts: 301
Joined: Thu Feb 23, 2012 6:51 am

Clear the user's cache

Post by Pavilion »

Hello:

Does anyone know how to clear a user's cache in php?

Thanks in advance - Pavilion
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Clear the user's cache

Post by Celauran »

You can't. You can prevent your site from being cached using Cache-Control, if that's what you mean.
Pavilion
Forum Contributor
Posts: 301
Joined: Thu Feb 23, 2012 6:51 am

Re: Clear the user's cache

Post by Pavilion »

Hello Celauran:

Here is an outline of my problem. Maybe there is a better solution than clearing the user's cache.
  1. My address book page allows the user to:
  2. Upload CSV address book files - This is task is run through the typical $_POST method action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"
  3. Delete address book contacts - using jQuery posts
  4. update contacts - using jQuery posts
  5. Add single contacts - using jQuery posts
After I upload a CSV file - I assume the cache is storing information used in that process. This causes problems upon trying to delete contacts from the address book. It is very plausible that a user would upload an address book file and then remove selected contacts he/she did not want to retain. Typically the deletion process works great (EXCEPT when I try and run it immediately after uploading a csv file). Then I get the following message:
clearcache.jpg
In my mind (new as it is to php) I figured if I could just clear the user's cache after uploading, it would solve the problem.

One other thorn in this particular thicket is that I don't want to completely stop the caching process because it is possible for a user to select contacts in the address book, move to another portion of the page (that does not display until called) and then want to move back to the original portion and recheck new contacts (without loosing originally checked contacts).

So... unless I'm mis-understanding the caching process, I need to find a way to clear the cache at selected times.

Any thoughts you have on the problem are certainly welcome.

Thanks Much:

Pavillion
Pavilion
Forum Contributor
Posts: 301
Joined: Thu Feb 23, 2012 6:51 am

Re: Clear the user's cache

Post by Pavilion »

Hello Celauran:

I think I figured it out:

At the end of my csv upload procedures I've inserted the following php script:

Code: Select all

$page = $_SERVER['PHP_SELF'];
header("Location: $page");
Inserting the above script solves the problem (at least as far as I can see). I can upload CSV files, then check selected individuals (one-by-one) and delete them. If there is something off with my solution, please let me know. I'd rather not run into bigger problems down the road, simply because I went about things the wrong way.

Thanks Much - Pavilion
Post Reply