Re: Javascript backslash in php dom object
| From: | Stuart Dallas | Date: | Mon, 12 May 2014 11:31:22 +0000 |
| Subject: | Re: Javascript backslash in php dom object | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-323290@lists.php.net to get a copy of this message | ||
On 12 May 2014, at 10:40, Uggla Henrik <Henrik.Uggla@kristianstad.se> 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/