Link to home
Start Free TrialLog in
Avatar of remmuh
remmuh

asked on

Product image cache issue in online store

I have created an online store for a client. I am creating the backend for the store and have included various different pages such as an add product page and an edit product page. The problem I am having on the edit product page is the fact that one the image is edited and the page reloads, the image is still the old one since it uses the same file name.

I have already tried adding random numbers in the URL and after the .jpg?3827958072305. I don't want to store the images in the db. Any suggestions?
ASKER CERTIFIED SOLUTION
Avatar of minichicken
minichicken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of remmuh
remmuh

ASKER

hmm, yes I think that could be a good way of doing it, only there is an extremely small chance that another image would get overwritten isn't there?
Avatar of remmuh

ASKER

unless, of course, I checked the name against the database. hmm.
If you need to overwrite the existing image with the new image,
You will need to retrieve the existing image file name, before you update the new file name to the DB.
And delete the old image with the retrieved file name.

Something like that to work around things... :)
Avatar of remmuh

ASKER

Sorry, what I mean by that was, since it is a random image, there is the very small percentage of a chance that a random number would come up the same as another one. But again, I can just check that against the db to see if there is another image with that name.
Oh I see what you mean, with md5(uniqid(rand())); I think it is really unique enough, with that you basically, generately a Random , Unique string with the 32 character length MD5 algorithm, with combination of alphabet and numbers.

So I dont think there should be a problem :) but it also good to check the DB, to make sure nothing happens.