themetman's picture

I have a problem on my site with images which I have uploaded to the site from my home not being refreshed on the page or block.

I have tried disabling the cache and I have even got the Block refresh module refreshing every 5 mins, but some items are refreshed, and others are not.

I even have a page with all images OK, but another not. Even if I manually refresh the page it does not update the images, just brings them up from a cache I suppose. If you want to have a look, compare the dates on the images on this page with this page

I have even done a

drush cc all

and still no good.

Any clues?

Most helpful answers

@themetman - I don't have an answer for you, but I'll brainstorm a few thoughts/questions that may or may not be helpful. Maybe, if you provide additional information - we can offer more suggestions.

1) How are you placing the images on the page? It looks like you've added them to the body field. Are you using the image widget in ckeditor?

2) Do you have any image fields on your nodes - is it different for images in the body field from images in an image field?

3) Are you using services like Cloudflare or other server based caching that might be overriding the Backdrop cache settings?

4) If you edit a node text and image, does the text update but not the image? Is this problem only with images or is other content effected?

5) Have you ruled out browser caching as the problem. If you open the site in a new browser, in an incognito window, or on a new computer - does it server the new or the cached image? Have you tried clearing your browser cache?

6) While views and blocks can have their own caching issues, it looks like your images are in the body field of a node page, so they should not be effected by either of those options. Clearing the Backdrop cache is good, but you've done that (hopefully more than once). 

If you figure this out, let us know what you find. Otherwise, proving more information might be helpful.

 

Comments

@themetman - I don't have an answer for you, but I'll brainstorm a few thoughts/questions that may or may not be helpful. Maybe, if you provide additional information - we can offer more suggestions.

1) How are you placing the images on the page? It looks like you've added them to the body field. Are you using the image widget in ckeditor?

2) Do you have any image fields on your nodes - is it different for images in the body field from images in an image field?

3) Are you using services like Cloudflare or other server based caching that might be overriding the Backdrop cache settings?

4) If you edit a node text and image, does the text update but not the image? Is this problem only with images or is other content effected?

5) Have you ruled out browser caching as the problem. If you open the site in a new browser, in an incognito window, or on a new computer - does it server the new or the cached image? Have you tried clearing your browser cache?

6) While views and blocks can have their own caching issues, it looks like your images are in the body field of a node page, so they should not be effected by either of those options. Clearing the Backdrop cache is good, but you've done that (hopefully more than once). 

If you figure this out, let us know what you find. Otherwise, proving more information might be helpful.

 

themetman's picture

Thank you @stpaultim for the brainstorm. I have checked by sshing into my site and the images have all been updated correctly.

To answer the questions in order:-

  1. Yes I am loading into the Body of a Book Page. I am using IMCE to select a file already on the web server from the image widget in ckeditor.
  2. These are not image fields.
  3. I am not using Cloudflare or other caching service as far as I know. Nor am I using HTTPS over DNS in the browser.
  4. Content seems to be fine when edited.
  5. I am using Firefox in Gentoo Linux, but I have tested in another Linux and in Windows 10 Edge (Yuck!) all the same. I have cleared the Browser Cache and opened in a Private Window and still stuck with the same images.

I have added a new Book Page with the same images, and will wait and see if it updates OK. I will post back in a day.

 

 

themetman's picture

Well, @stpaultim  I added the new Book page with the images, and also deleted the images on the Block and reinstalled them, and the images now refresh when the page refreshes.

No idea why it was misbehaving but that has fixed it.

Thanks once again for your help.

I don't know if this is connected with problem, but I noticed a difference between image folders the two pages:

In one that images are not updated, the images are located in the files/resize/met folder. On the other page they are in the files/met folder.

This leads me to the idea that on a page where there are no problems, the images are not resized when uploading.

So this (the “resize” folder) leads me to think that it may be related to the IMCE Role-profile assignments and settings for resizing uploaded photos and the specific profile settings in admin/config/media/imce/profile/edit/1 (or other profile number).

It may have nothing to do with it, but I give an idea that came to my mind.

themetman's picture

Sorry to be slow to get back, @amilenkov, you could be right with the location of the file which has been resized. I will sort this out tomorrow, and let you know.

themetman's picture

OK here is something to think about, @amilenkov. You are correct, here is the source of that image if you look at the page and open the source in Web developer (I am using Firefox in Linux):

<img alt="Barometric Pressure and Rain Last 24 Hrs" height="178" src="/files/resize/met/_R-PressRain24CS-347x178.png" width="347" />

and if you edit the page and look at the source here is the the source for the first image which is not displaying correctly

<img alt="Barometric Pressure and Rain Last 24 Hrs" height="178" src="/files/met/_R-PressRain24CS.png" width="347" />

very strange!!!! How can I fix that one?

themetman's picture

I know this is a while since my last comment, but I have an answer to this I think.

So @amilenkov particularly but also @stpaultim, I have at last worked out why these files go in the resize folder:

When adding an image from the server using the IMCE module it automatically adds a size which is the size of that image. Then this is renamed and put in the resize folder, so is never updated when the image changes on the server as it should do.

If, when adding an image, you remove the image size before saving, it is not resized, and so is always coming from the original folder and will be updated when it changes.

BINGO!!!

themetman's picture

I am still having problems with images not refreshing in both Firefox and Chromium. They are updated on my server every 5 minutes, but when the page is refreshed the images are not.

If I clear the Image Cache then the image is updated.

If I disable the cache in Firefox setting browser.cache.disk.enable to false then the images update fine.

I have even tried these images in a Block with the Block Refresh module. That used to work fine, but now the block disappears if the module is used! I have reported this as an issue.

I have gone through all the items listed by @stpaultim and have found that it is due to the browser. I have cleared the Backdrop Cache which makes no difference. Looking in the Web Devel the images are not loaded from the resize area, definitely from the original location.

I have all sorts of stuff updating on my site relating to my Weather Station, Energy Production and so on which I like to keep an eye on, so images and graphs not updating is very frustrating.

I have even written a simple module to display some images, but I have the same problem.

Any ideas would be most welcome.

Hi @themetman - it was good to see you at Backdrop Live.  One idea; if the images are generated images, is it possible to give each image a unique name each time it updates?  And then have a view look for the latest image (you might need to purge the old images, but a rule could possibly do that)

There is views_autorefresh which may help if this works.

themetman's picture

Hi @yorkshirepudding. Yes a good session I thought.

I just installed views_autorefresh and added a global refresh to a Views Page which displays the page with the images on it. Unfortunately the images are not refreshed.

As far as my module goes, I have looked at adding a random query to the end of the image name in my module so it is reloaded, but I cannot get that to work as per this which adds ?t=<RANDOM_NUMBER> to the end of the image URL:

 

function build_image($_image){
  $image_url = 'public://met/' . $_image;
  if (file_exists($image_url)) {
    $build['image'] = [
      '#theme' => 'image',
      '#uri' => $image_url . '/?t=' . time(),
    ];
  }
  return $build['image'];
}

 

but no images show up. If I add the ?t=<RANDOM_NUMBER> to the image url in the browser the image does show up fine and if I change the number it is reloaded correctly.

Can you spot anything I am doing wrong in the function above.

Most grateful for your input.

EDIT -------------------------------------------------------

Got it working now, I have a forward slash in front of the 't' so that line in the function should look like this:

'#uri' => $image_url . '?t=' . time(),

BINGO!!! Hopefully it will work on my phone. I will check

So lots of simple module writing needed now.

 

Great stuff.  Interesting site BTW.

themetman's picture

Well I am back with this same problem and it is nearly 2 years on.....

I have tried to remove the Image Resizing which helps.

If I open the page in a Private Tab, then the images load correctly and are up to date. However when I refresh the page the page is updated as can be seen from the time changing on the page, but images are not updated, staying at the original time, so are being loaded from the cache by the browser (Brave on Linux in my case)

A case in point is here https://themetman.net/tellicast-stats and follow the link to any of the three options to see the problem. This is my Weather Satellite Reception Status. 

Or look here https://themetman.net/book-page/campbell-scientific-station-graphs-last-24-hrs for what is meant to be updated Weather Station Graphs every 5 mins or so. Wait a bit, reload the page, and the images are not updated as they should be. Load the page in to a private tab and they are.
The first example is from a static html page, the second is from a Backdrop Page.

I have created a static site at https://tellicast.themetman.net/ with the same page for the tellicast stats, but copied to the new site, and that is working well, it updates correctly when refreshed.

It must be something to do with Backdrop.

I am 99.99% sure I am not using CloudFlare Caching for my DNS.

What is going on?