html - Comparing XML documents for changes in PHP -


Currently I'm using PHP (non-local) to load many codes around the web Simplexml_load_file ()) . This, as you can imagine, this is a very difficult process and slowing down the load time (7 seconds to load 7 files), and possibly more files to load. These files do not change often, but as soon as they are done, then there should be a change on the page.

One idea was to cache the version of each feed and the HTML output generated from that feed in my DB. Then, each time the user loads, the feed is compared; If they are different then I will run my existing code, generate HTML, output it, and save DB. However, if this is the same, then I can only output cached HTML.

I have two concerns with it:

Security: If I am saving a copy of an XML file, can it be a security threat, because I can not Does not control the content of?

Speed: Its main goal is to increase the overall page load speed. Does the process given above increase the speed, or will it give down the server to do more? Thanks for your help!

A cron job crawling through every external XML source, say, per hour Update this quarter-hourly and if necessary?

This 100% will not be in real time, but will load from your web page - which will always use cached files, I do not think that except for actually downloading files, external sources for updates There is a reliable method of voting (in theory, it is possible to get the correct cache header, but I will not be configured correctly.)

Security: If I have an XML fileOpi I handle, so it can cause a security risk, because I do not control the content of the file?

To make it very rare, store cached XML files outside of the web root. Whatever the hazard remains, it is the same as you are going through the live stream. Were.


Comments