views:

69

answers:

3

Hi there,

I'm working on a site in Drupal which will reside at http://sub.clientdomain.com, pulling in an static html fragment from a server on at http://clientdomain.com/path/to/fragment.html, which I need to display in a page, to give a parent menu for a site.

I'm working on a VPS, so I have access to curl, wget and pretty much anything I want to install.

What's the optimal way to do this?

+4  A: 

My first approach here would be to use curl on a cron job every n minutes to pull in the html fragment, and then store it somewhere like /var/www/html/site, to save making the http request on each load.

I'd then use file_get_contents function to pull the content into the page , with a fallback if the file isn't there (lets say if the file isn't there for example).

I'm adding this here mainly as a sanity check - would love to see other approaches to it.

Chris Adams
+1  A: 

Your first approach sounds like a good idea. By using a cronjob, the pulling of the content is separated from your site, so the user doesn't have to wait. If you have access to the page that generates the fragment, you could reduce net traffic by actively sending the new content instead of requesting it every couple of minutes.

I'd store the fragment in a database, though, as I believe database-queries are faster than access to the filesystem.

Select0r
A: 

If that main domain is on the same server, you will probably have access to directly, so use just the simple include and point the static html file by absolute path

Pentium10
Thanks Pentium10 - but I should have added that it's on another server.
Chris Adams