Forum Moderators: coopster
<datavalues>
<units>F</units>
<sensor1temp>xx.x</sensor1temp>
<sensor2temp>xx.x</sensor2temp>
<sensor3temp>xx.x</sensor3temp>
<sensor4temp>75.7</sensor4temp>
<relay1state>0</relay1state>
<relay2state>0</relay2state>
</datavalues>
I would like to display the sensor4temp (75.7) on a web page but I don't want users to access the device every time they access the web page. Is there a way to read the device every 10 minutes or so (on the server side) and save the sensor4temp value in file such that my web page would get the value from the file, on the server, and not directly from the device?
Any ideas would be greatly apprciated.
Thanks Gary
[edited by: coopster at 5:45 pm (utc) on July 9, 2009]
[edit reason] no domain signatures please and thanks :-) [/edit]
<snipped personal url, see Terms of Service and Forum Charter please>
[edited by: coopster at 5:46 pm (utc) on July 9, 2009]
[edit reason] removed url per TOS [webmasterworld.com] [/edit]
If you had "72.5" in a file, how would you display it in your above example?
[edited by: coopster at 5:50 pm (utc) on July 9, 2009]
[edit reason] removed url per TOS [webmasterworld.com] [/edit]
1. User accesses webpage.
2. Check timestamp of cache (your static XML/Temperature file)
3. If timestamp <= 10 mins ago then serve the value in your cache to the user (ie. Read your static file.)
4. If timestamp > 10 mins ago then request state.xml (as you do at the moment), save this (the output) in your cache and serve this value to the user.
CRON will be working away even when no one is accessing your site. If you were wanting to record the values every 10mins, regardless of who was accessing the site, then you would need CRON.