Boards.ie uses cookies. By continuing to browse this site you are agreeing to our use of cookies. Click here to find out more x
Post Reply  
 
Thread Tools Search this Thread
22-11-2019, 15:22   #1
Supercell
Happy :)
 
Supercell's Avatar
 
Join Date: May 2001
Posts: 12,660
Help prevent image caching for website webcam

I've been reading many many support websites on this and feel like I'm getting nowhere, I'm really stumped, if anyone has any sugggestions on how to make this work I'd really appreciate it.

My weather website home page displays a static image which is updated every few minutes by ftp. The image is always named webcam.jpg.

No matter what i do it seems i cannot make chrome or any other browser not load a cached image if the page has been visited before (other than using shift-f5 , regular refresh doesnt work).

Unfortunately I cannot post the code in a bb code tag for some reason or cloudflare is blocking me - you can see the page i'm talking about at https://www.loughlinstown.ie/index.html (have a look at the header and script i've put on top of that for example of what i've been trying)


What I'd like to have working is something like the link I got from the sat24 website to display their image : https://api.sat24.com/mostrecent/GB/visual5hdcomplete ->> how is this displaying anything ???
Its maybe pulling timestamped images which I guess I could try and do (the images are pulled off my ip camera on a raspberry pi 2 running rasbian and then cron uploads to the website directory).
It should be easy enough to append the time or a random number i think in rasbian to the filename but then that would present other issues - filling up space on the website host and also on my raspberry pi sd card and also how to call the new image name.

I'm really struggling.

Any help really appreciated!
Supercell is online now  
Advertisement
28-11-2019, 16:28   #2
Trojan
Ask me about websites
 
Trojan's Avatar
 
Join Date: Feb 1998
Posts: 15,645
Send a message via Skype™ to Trojan
You need a HTTP header telling it not to cache. Experiment with these:

Apache - add this to your .htaccess file:
Code:
<files "webcam.jpg">
    Header set Cache-Control "no-cache"
</files>
Nginx - add this to your Nginx configuration file:
Code:
location ~/path/to/webroot/webcam.jpg {
    add_header Cache-Control "no-cache";
}
Trojan is offline  
(3) thanks from:
29-11-2019, 09:19   #3
Supercell
Happy :)
 
Supercell's Avatar
 
Join Date: May 2001
Posts: 12,660
Quote:
Originally Posted by Trojan View Post
You need a HTTP header telling it not to cache. Experiment with these:

Apache - add this to your .htaccess file:
Code:
<files "webcam.jpg">
    Header set Cache-Control "no-cache"
</files>
Nginx - add this to your Nginx configuration file:
Code:
location ~/path/to/webroot/webcam.jpg {
    add_header Cache-Control "no-cache";
}
Cannot thank you enough Trojan, finally, its working!, really really grateful for your help.
Supercell is online now  
Thanks from:
29-11-2019, 18:50   #4
Trojan
Ask me about websites
 
Trojan's Avatar
 
Join Date: Feb 1998
Posts: 15,645
Send a message via Skype™ to Trojan
Excellent, delighted to hear it worked for you. If you want to give back, hit up my business socials linked in sig - any Likes/Shares/Comments/etc hugely appreciated as I am just getting this started. No obligation - I'm glad to help.
Trojan is offline  
Thanks from:
Post Reply

Quick Reply
Message:
Remove Text Formatting
Bold
Italic
Underline

Insert Image
Wrap [QUOTE] tags around selected text
 
Decrease Size
Increase Size
Please sign up or log in to join the discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Share Tweet