OMG! I just did the coolest thing!
Dec. 9th, 2018 12:13 pmSo, I'm writing an RSS reader, because (as mentioned before, I think) I dislike my free options. It is going really well so far. I had a dust-up with phpFastCache, which was supposed to implement caching for me but didn't work (perhaps because of my hosting provider). So, I wrote my own caching function, which was incredibly simple and fast. That definitely helped with the speed of the page loading... after the first load or two. That first load, though, is slow. I made some changes so that now the cache is valid for between 10 and 15 minutes (so that all the cached pages aren't updated at once) and now I also check to see if the remote RSS feed has been updated. No point in downloading a new file if nothing has changed. However, that still left me will a load time that was so long at first that sometimes the page times out.
To fix this, I added in a little script that measures how long the page has been loading and if it is more than 5 seconds, then I cancel any more downloading of feeds, print a message about the page loading, and restart (because by restarting, I will automatically use local (cached) versions of all the pages that were already valid (either because I downloaded the new copy or because they were the current version)). The code I added to do this worked slightly differently than I expected (although I wasn't exactly sure where the breaks needed to be to get the right result). The result, however, is awesome.
Instead of printing nothing but the loading message, the page prints all of the data that has already loaded and then goes on to continue checking for updates. It is much cooler than I had intended, and I love it. I've also cleaned up the parsing of some feed descriptions (mainly from Tumblr) that were messy/badly formatted and implemented sorting by category and deleting of feeds. Next, I need to implement a timeout for contacting remote servers that depends on how long the page has already been loading. That way (using my cool new loading feature), I can load the majority of the content while the page tries to load stuff from slow remote servers.
To fix this, I added in a little script that measures how long the page has been loading and if it is more than 5 seconds, then I cancel any more downloading of feeds, print a message about the page loading, and restart (because by restarting, I will automatically use local (cached) versions of all the pages that were already valid (either because I downloaded the new copy or because they were the current version)). The code I added to do this worked slightly differently than I expected (although I wasn't exactly sure where the breaks needed to be to get the right result). The result, however, is awesome.
Instead of printing nothing but the loading message, the page prints all of the data that has already loaded and then goes on to continue checking for updates. It is much cooler than I had intended, and I love it. I've also cleaned up the parsing of some feed descriptions (mainly from Tumblr) that were messy/badly formatted and implemented sorting by category and deleting of feeds. Next, I need to implement a timeout for contacting remote servers that depends on how long the page has already been loading. That way (using my cool new loading feature), I can load the majority of the content while the page tries to load stuff from slow remote servers.