Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4019) - 03 April 2024

Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

Day / Night graphic keeping current

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderator: daj

Post Reply
RayProudfoot
Posts: 3390
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Day / Night graphic keeping current

Post by RayProudfoot »

Many of us have added the Day / Night graphic to our websites over the years. It's a great way of seeing how much daylight the site has.

It also includes a marker for the current time but I have to manually refresh my page on Windows to show the current situation. On iOS it's a real pain as no refresh works.

Here's the code. Any chance of adding an instruction to my .htaccess file to keep it current? Thanks. :)

<td rowspan="5"><img id="img_sun"
src="http://cheadlehulmeweather.co.uk/heavens.php"
width="115" height="115"
alt="Day/Night/Twilight" title="Day/Night/Twilight" style="text-align:center" border="1"/></td>
<td rowspan="5">
Cheers,
Ray, Cheshire.

Image
User avatar
saratogaWX
Posts: 1202
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: Day / Night graphic keeping current

Post by saratogaWX »

The issue is caused by caching being enabled by your webserver for the .png image file created by heavens.php script.

For a simple test solution, try changing

src="http://cheadlehulmeweather.co.uk/heavens.php"

to

src="http://cheadlehulmeweather.co.uk/heavens.php?t=<?php echo time();?>"

to try and defeat the browser caching the image.

Otherwise, you'll need to change the cache configuration of the webserver for .png images to either set it to 1 hour or disable it.
RayProudfoot
Posts: 3390
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Day / Night graphic keeping current

Post by RayProudfoot »

@saratogaWX, many thanks. I’ve updated my template and it will be executed in a few minutes.

It may take a little while to judge if it’s fixed. If further work is required I’ll come back as I’m unfamiliar with changing cache settings. Fingers crossed it works.
Cheers,
Ray, Cheshire.

Image
RayProudfoot
Posts: 3390
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Day / Night graphic keeping current

Post by RayProudfoot »

I’ve checked on my iPad and Android phone as well as my windows laptop and it looks like your code has fixed it. :clap:

Many thanks! That has been bugging me for years! :D
Cheers,
Ray, Cheshire.

Image
alexm2192
Posts: 1
Joined: Mon 29 Jan 2024 1:17 pm
Weather Station: Davis Vantage Pro2
Operating System: Windows XP

Re: Day / Night graphic keeping current

Post by alexm2192 »

Unfortunately, there's no simple .htaccess tweak that can automatically refresh that external image source. The heavens.php script would need modifying to add metadata headers allowing the image to cache for only a few seconds.

However, a workaround for self-refreshing the image would be to wrap it in some JavaScript. For example:

Code: Select all

<script>
  setInterval(function() {
    document.getElementById('img_sun').src = 'http://cheadlehulmeweather.co.uk/heavens.php?rand=' + Math.random();
  }, 10000); 
</script>
This would append a random query string to "trick" the image into refreshing every 10 seconds.

Not as seamless as having the PHP script handle expires headers but could save needing manual refreshes. Let me know if you give that a try or have any other questions! A contract template is a pre-written document that provides a standard format and outline for creating a contract.Stepping into the trucking industry as an owner-operator comes with several decisions, one of the most significant being the choice of a comprehensive Owner Operator Lease Agreement template.
Last edited by alexm2192 on Tue 30 Jan 2024 4:23 pm, edited 1 time in total.
RayProudfoot
Posts: 3390
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Day / Night graphic keeping current

Post by RayProudfoot »

@alexm2192, it looks like you didn’t see Saratoga’s suggestion which has solved it without the need to edit .htaccess. :)
Cheers,
Ray, Cheshire.

Image
Post Reply