-2

I have this slider, I created a panel so you can upload there the images and modify the order of display, but you can upload the image to the server and the changes do not appear unless you clear cache-

Hex
  • 47
  • 6

2 Answers2

0

You can change the url to trick the browser.

For example instead of having a url like this :

https://mydomain/myimage.png

you can add a parameter so that the browser see a new url.

https://mydomain/myimage.png?v0.0.1

In this example i used a version tag, and you can change it manual on demand (so that you do keep using cache but in your way). When you change that parameter, the browser will see a new url, so it will load the image again.

You can also use a timestamp instead of a version tag.


Edit (some more info)

Adding the time on the url will "force" the browser to get the image every time.

Example

https://mydomain/myimage.png?date=2017-04-28_10-06-00

Also, in the developing state, you can use on your browser ctrl+F5 to clear the page's cache and reload the page.

Cache is something helpful and you should try to use it, so disabling it completely is not a good solution.

Some relative answers including php solutions can be found here : PHP force refresh image

Community
  • 1
  • 1
GramThanos
  • 3,572
  • 1
  • 22
  • 34
  • the problem is that the webpage requires live updates, for example if the user deletes an image from the gallery I'm making it refresh but the image is still there (but not in the server or database) so its kind of frustating having to delete the cache, I'm even by jquery making a location.refresh(true) but it doesnt work, I have to f5 two or 3 times to make it dissapear/appear (the image) – Hex Apr 28 '17 at 06:28
  • If you want every time the browser to get the new version, you can use a timestamp (as i say). A timestamp is a "format" for the time so the url will change every time. On javascript you can get a timestamp using `new Date().getTime();`. – GramThanos Apr 28 '17 at 07:01
0

the problem is that the webpage requires live updates, for example if the user deletes an image from the gallery I'm making it refresh but the image is still there (but not in the server or database) so its kind of frustating having to delete the cache, I'm even by jquery making a location.refresh(true) but it doesnt work, I have to f5 two or 3 times to make it dissapear/appear (the image)

You can use AJAX for this. Have a look at this thread, it might help you. Have a nice day :) Using AJAX / jQuery to refresh an image

Community
  • 1
  • 1
S. ter Keurs
  • 57
  • 1
  • 9