Re: Javascript backslash in php dom object

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12 May 2014, at 10:40, Uggla Henrik <Henrik.Uggla@xxxxxxxxxxxxxxx> wrote:

> 1. The clients should not rely on http://ol3js.org, it could be down/slow.
> 2. The server should always have the most recent version of the js available at http://ol3js.org.
> 
> I could do what you propose but I would then need to implement a mechanism for checking and replacing the js on my server.

Yes, you would, so do that. Your current "solution" doesn’t actually solve the problem you’re trying to address:

By having your PHP script download it from that third party site you are not preventing this issue, you’re just moving it from the client to the server. The client is still at the mercy of the speed and uptime of their server(s).

A better solution would be to have a cron job (in PHP or bash or whatever) that downloads the file from the third party to a temporary file, then move that file into your site’s filesystem. Then reference your site’s copy of that file in your script tag. Make sure you use a temporary file rather than downloading it directly into place to avoid clients trying to download while it’s being retrieved.

Run that cron job as often as you think is needed to make sure it’s always up to date. Ideally that script will make use of If-Modified-Since/Etag/whatever caching mechanism is available from the third party server to not bother actually downloading it unless it’s changed. I’d probably run the script daily, or hourly if it’s very important that it’s always the latest version (it rarely is that important).


-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php






[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux