KWSullivan Posted October 13, 2009 Share Posted October 13, 2009 I have limited experience with php and its been a year or two since I've last used it. I have a small web application where I want to make sure the data presented on a page (currently an HTML file) is no older than 60 seconds. The page automatically refreshes every 15 seconds. I was think about renaming the file by placing the php rename() function at the end of the file. Will this work or will the script be executed before the page is viewed? Any other suggestions? Thanks, Ken Quote Link to comment https://forums.phpfreaks.com/topic/177588-delete-html-file-after-loading/ Share on other sites More sharing options...
mikesta707 Posted October 13, 2009 Share Posted October 13, 2009 are you creating a new HTML file every 60 seconds? Quote Link to comment https://forums.phpfreaks.com/topic/177588-delete-html-file-after-loading/#findComment-936349 Share on other sites More sharing options...
johnsmith153 Posted October 13, 2009 Share Posted October 13, 2009 I think you are talking about getting javascript to force the browser to reload/refresh every 15 seconds. Is this correct? What data will you be displaying on the page? A HTML page will hold static data so you will just be reloading the same page. If you had a page (probably php) that searched a database to display current data then this would work. Every time the browser reloaded the page, php would search the database and display current, up-to-date data. Please explain a little more and I can help. Quote Link to comment https://forums.phpfreaks.com/topic/177588-delete-html-file-after-loading/#findComment-936350 Share on other sites More sharing options...
Maq Posted October 13, 2009 Share Posted October 13, 2009 Any other suggestions? Have you considered using AJAX? Seems like the best solution in this case. Quote Link to comment https://forums.phpfreaks.com/topic/177588-delete-html-file-after-loading/#findComment-936351 Share on other sites More sharing options...
KWSullivan Posted October 13, 2009 Author Share Posted October 13, 2009 I'm using <META HTTP-EQUIV="REFRESH" CONTENT="15"> to refresh the page. My data system dumps an new HTML file every 5 seconds. Quote Link to comment https://forums.phpfreaks.com/topic/177588-delete-html-file-after-loading/#findComment-936353 Share on other sites More sharing options...
mikesta707 Posted October 13, 2009 Share Posted October 13, 2009 if your "data system" puts new info on the html page every x seconds via php or something, than there is no need to rename the file, or delete it or anything. I'm very confused on how your system works though... However, if your data system makes a new html page with new info, than, if the new page is the same name as the old page, you don't have to do anything either. but i have no clue what or how your system does what it does Quote Link to comment https://forums.phpfreaks.com/topic/177588-delete-html-file-after-loading/#findComment-936357 Share on other sites More sharing options...
KWSullivan Posted October 13, 2009 Author Share Posted October 13, 2009 I have a script in my data system that retreives the data in XML format, transforms it, and writes/overwrites an html file. I need to load php on the web server anyway so I thought I'd see what possibilities it presented. I'm also thinking about using a script or rule to delete any files in the folder that are older than a minute or so. The reason behind this is if something in the data system fails the clients won't find the file and it will be obvious something is wrong (404 error). In this case that's better than displaying inacurate data. Ken Quote Link to comment https://forums.phpfreaks.com/topic/177588-delete-html-file-after-loading/#findComment-936359 Share on other sites More sharing options...
mikesta707 Posted October 13, 2009 Share Posted October 13, 2009 well, I would just let it overwrite naturally. Unless you can get the timing perfect, you may run into the problem of a user trying to access the file after it was deleted, but before it was updated. Quote Link to comment https://forums.phpfreaks.com/topic/177588-delete-html-file-after-loading/#findComment-936362 Share on other sites More sharing options...
KWSullivan Posted October 13, 2009 Author Share Posted October 13, 2009 Overwriting works fine. My concern is if something goes wrong in my data server and it stops overwriting the html file (the filename is always the same for a given client). The clients will keep refreshing but the data will no longer be up to date. If the client, or a server side script, always deleted or renamed the html file after it was loaded by the client, the client would not find the file during the next refresh. This would generate a 404 error and the client would be aware there was a problem with the server. This is not your average web server application. I'm basically using a web browser to display the current conditions in a process room. The current conditions reside in my data server and are dumped to the html file. I'm looking at all points of failure and trying to provide solutions. The worst thing I could do is display old data. Quote Link to comment https://forums.phpfreaks.com/topic/177588-delete-html-file-after-loading/#findComment-936371 Share on other sites More sharing options...
mikesta707 Posted October 13, 2009 Share Posted October 13, 2009 I see, well in that case, look into the unlink function. I don't really know what will happen when A file tries to delete itself though Quote Link to comment https://forums.phpfreaks.com/topic/177588-delete-html-file-after-loading/#findComment-936382 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.