Search…

X3 Photo Gallery Support Forums

Search…
 
trpgforum
Experienced
Topic Author
Posts: 105
Joined: 05 Jul 2019, 03:40

Old image version is displayed after upload a new one

22 Jul 2023, 09:05

Hello Karl

I've had an annoying problem with the image cache for a few years. I think I remember making an inquiry about this a long time ago.

But now that I've realized how much time I've lost with this problem over the past few years, I'm happy to describe it today. It occurs, for example, with the link to the exhibition flyer on my website https://www.thomas-ruf.ch/ausstellung/.

1.) Upload image to gallery (graphic)
2.) Insert href link to image (scr) in the text of the website
5.) Everything OK: Image is displayed correctly!

The image from step 1 must now be replaced in the gallery. The name must of course remain because of the href entry.
To do this, I proceed as follows

4.) Switch to the gallery
5.) Upload new image
6.) View uploaded image.

Now I can do what I want: save the page, make a change and save it, close the browser again. The graphic link still shows the old image!

In the gallery, if I rename the image and adjust the image path in the href link, the correct image is displayed. If I change the name back again, the old picture appears again!

I've also tried cache clean etc. it's no use at all!

Neither does deleting the old image and saving the page before uploading the new one. It seems to me that the problem almost always occurs, but not always.

I work with the current Edge browser.

Do you have any idea what could be causing this?

Best regards
Thomas
THOMAS RUF PHOTOGRAPHY
Landscape - Nature - Macro
4132 Muttenz
Switzerland
www.thomas-ruf.ch
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13998
Joined: 30 Sep 2006, 03:37

Re: Old image version is displayed after upload a new one

22 Jul 2023, 22:06

Hi Thomas,

This is your browser cache, and it's basically working correctly. When you have an image imagename.jpg and you replace it with another imagename.jpg, the cached version will still remain in browser (and on CDN networks, for example if you use Cloudflare). This is how caching works unfortunately, unless you want your browser (and everyone's browser) to never ever cache anything on your website, but that is very inefficient. This has nothing to do with the "cache" options in X3, which are related to caching page responses on the server and resized images.

That's why file renaming is the way you would normally need to deal with updates file names. Or even easier, you could also append a ?v=2 parameter into the HREF and SRC references for the image. Updating a ?parameter at the end of url will force new requests. Obviously you would need to update the parameters ?v=3 ?v=4 every time you change the file.

I'm not sure if you expected another solution, but caching by file name/path is how the internet and browsers work.
 
trpgforum
Experienced
Topic Author
Posts: 105
Joined: 05 Jul 2019, 03:40

Re: Old image version is displayed after upload a new one

23 Jul 2023, 05:15

Hello Karl
Thank you!
Your answer is mostly understandable and comprehensible for me. However, the following is not entirely clear to me:

1. Why does clearing the browser cache not help? I tried this too.

2. How long do I have to wait for the cache problem to resolve itself?

3. How long does it take for the issue to resolve itself when using CDN / Cloudflare?

Best regards
Thomas
THOMAS RUF PHOTOGRAPHY
Landscape - Nature - Macro
4132 Muttenz
Switzerland
www.thomas-ruf.ch
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13998
Joined: 30 Sep 2006, 03:37

Re: Old image version is displayed after upload a new one

23 Jul 2023, 11:04

trpgforum wrote:1. Why does clearing the browser cache not help? I tried this  too.
This will work, unless you are also using Cloudflare CDN, which is another level of cache. There is nothing else that is "caching" your images, because X3 can't and doesn't maintain any cache for direct requests to images.

For testing, you could "open image in new tab", and then in the url, just add some ?v=1 at the end.
trpgforum wrote:2. How long do I have to wait for the cache problem to resolve itself?
3. How long does it take for the issue to resolve itself when using CDN / Cloudflare?
Technically, it could be up to a year, and therefore it is not a solution to "wait".

Why not rename your images after updating? Or simply add a ?param=1 in the SRC/HREF references to image after updating? I understand your frustration, but cache is an integral part of the internet, and static assets (like images) are usually instructed to cache. Pages (html) on the other hand will normally NOT cache, because they get updated frequently.

I could add some rule in your .htaccess file that instructs browsers to NOT cache images from your website, but I don't think this is a good solution.
 
trpgforum
Experienced
Topic Author
Posts: 105
Joined: 05 Jul 2019, 03:40

Re: Old image version is displayed after upload a new one

23 Jul 2023, 12:00

Hello Karl

Thank you, now I know everything I need to know. You explained it excellently. And I'm not frustrated at all - it was just a matter of fully understanding the matter. And now I know the trick with the parameter ?v=1 that solves the problem in hrefs.

Incidentally, there are definitely reasons why a newly loaded image version should not be renamed. Photographers sometimes only find out that the image has a speck of dust after uploading it to the gallery. The image is corrected and then re-uploaded to replace the old image with the dust stain. But of course the file name that corresponds to the picture number must not be changed, otherwise there will be problems when the customer wants to order...

Thank you again and best regards
Thomas 
THOMAS RUF PHOTOGRAPHY
Landscape - Nature - Macro
4132 Muttenz
Switzerland
www.thomas-ruf.ch
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13998
Joined: 30 Sep 2006, 03:37

Re: Old image version is displayed after upload a new one

23 Jul 2023, 23:39

Thanks for highlighting your user experience with caching, it definitely can be confusing.
 
trpgforum
Experienced
Topic Author
Posts: 105
Joined: 05 Jul 2019, 03:40

Re: Old image version is displayed after upload a new one

25 Jul 2023, 01:42

Hello Karl

But one final thought: I could use ?t='.time().' append in the scr element. Then I don't have to adjust the number manually after each upload of a new image version. I came across an entry in Google that reads the time differently. In my opinion, this should also apply to our case. Or could there be problems with that?

Best wishes
Thomas
THOMAS RUF PHOTOGRAPHY
Landscape - Nature - Macro
4132 Muttenz
Switzerland
www.thomas-ruf.ch
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13998
Joined: 30 Sep 2006, 03:37

Re: Old image version is displayed after upload a new one

26 Jul 2023, 00:40

Appending ?time in the url would solve your problem, but it also blocks cache because each request would be different.

In your case, for some images that you embed manually and might get renamed, it might make sense. In general, it shouldn't be used, because then you might as well entirely disable caching.
 
trpgforum
Experienced
Topic Author
Posts: 105
Joined: 05 Jul 2019, 03:40

Re: Old image version is displayed after upload a new one

26 Jul 2023, 02:38

Of course I will only use it specifically in 2 places. That solved the problem for me!

Thanks very much!
Thomas
THOMAS RUF PHOTOGRAPHY
Landscape - Nature - Macro
4132 Muttenz
Switzerland
www.thomas-ruf.ch