Search…

X3 Photo Gallery Support Forums

Search…
 
User avatar
andreamarucci
Experienced
Topic Author
Posts: 312
Joined: 01 Mar 2011, 11:13

Re: Using a CDN

02 May 2016, 12:07

No sorry. If the CDN work with forum.kog.it is has to work also with gallery.kog.it

Maybe the problem is only related to relative paths vs. absolute and putting all the paths as absolute, if possible, should solve it.

Very grateful if you can help since the gallery handle most of the traffic and it has to work through the cdn...
 
User avatar
andreamarucci
Experienced
Topic Author
Posts: 312
Joined: 01 Mar 2011, 11:13

Re: Using a CDN

02 May 2016, 13:26

Is there something I can do here maybe?
Schermata 2016-05-02 alle 19.25.53.png
Schermata 2016-05-02 alle 19.25.53.png (2.46 KiB) Viewed 7936 times
 
User avatar
mjau-mjau
X3 Wizard
Posts: 14469
Joined: 30 Sep 2006, 03:37

Re: Using a CDN

02 May 2016, 13:39

I don't get it ... First of all, I have two answers for you to two completely different topics.

First of all, I notice now that you aren't even using the CDN for your images loaded from X3. Haven't you added the CDN URL as in your screenshot? That would be necessary.

As for the caching issue, since you are not even loading images from the CDN with X3, then it's not related. Even if it you do manage to start loading images in X3 from the CDN, this has nothing to do with X3 if images don't seem to cache on the CDN persistently.
 
User avatar
andreamarucci
Experienced
Topic Author
Posts: 312
Joined: 01 Mar 2011, 11:13

Re: Using a CDN

02 May 2016, 14:29

mjau-mjau wrote:First of all, I notice now that you aren't even using the CDN for your images loaded from X3. Haven't you added the CDN URL as in your screenshot? That would be necessary.
The screenshot is actually taken from my settings. i've inserted the CDN url from the very start. If you want to check my panel I can give you my credentials.
mjau-mjau wrote:As for the caching issue, since you are not even loading images from the CDN with X3, then it's not related. Even if it you do manage to start loading images in X3 from the CDN, this has nothing to do with X3 if images don't seem to cache on the CDN persistently.
I'm loading images from the CDN but not as it should be. The problem is the one pointed out by the technician at CDN77. Since all the url are relatives, if I enter the gallery using the CDN url, all the images are taken from the CDN; if I enter the gallery with the regular url, they're taken from my server.

Any idea on how to solve this problem?
 
User avatar
andreamarucci
Experienced
Topic Author
Posts: 312
Joined: 01 Mar 2011, 11:13

Re: Using a CDN

02 May 2016, 14:35

Try this. Go to this url

http://gallery.kog.it/20112015/2013/130113/

and you'll see that the first image has this url

<img src="/render/w480-q90/4.20112015/3.2013/1.130113/20130110_084821.jpg" style="height: 266px;" data-src="/render/w480-q90/4.20112015/3.2013/1.130113/20130110_084821.jpg" alt="20130110 084821" itemprop="thumbnail">

that's relative, so taken from my server.

But if you go at the same address using the CDN url, the same relative URL is "relative" to the CDN so the images are taken from the CDN.

The problem is only that IV is using relative URL so if I enter with my server URL, the images are taken from my server, if I enter with the CDN URL, are taken from the CDN...

Basically it seems that the CDN URL is not taken into consideration at all...
Last edited by andreamarucci on 02 May 2016, 14:41, edited 1 time in total.
 
User avatar
andreamarucci
Experienced
Topic Author
Posts: 312
Joined: 01 Mar 2011, 11:13

Re: Using a CDN

02 May 2016, 14:39

andreamarucci wrote:Is there something I can do here maybe?
I've tried to put the CDN url also in the other field but it doesn't work as you can imagine :-)
 
User avatar
mjau-mjau
X3 Wizard
Posts: 14469
Joined: 30 Sep 2006, 03:37

Re: Using a CDN

02 May 2016, 14:46

andreamarucci wrote:
mjau-mjau wrote:First of all, I notice now that you aren't even using the CDN for your images loaded from X3. Haven't you added the CDN URL as in your screenshot? That would be necessary.
The screenshot is actually taken from my settings. i've inserted the CDN url from the very start. If you want to check my panel I can give you my credentials.
Well, it looks like the CDN url could be malfunctioning ... Yes please, I would like panel access.
mjau-mjau wrote:I'm loading images from the CDN but not as it should be. The problem is the one pointed out by the technician at CDN77. Since all the url are relatives, if I enter the gallery using the CDN url, all the images are taken from the CDN; if I enter the gallery with the regular url, they're taken from my server.

Any idea on how to solve this problem?
Sorry this is wrong. X3 isn't loading images from the CDN at all ... Not sure where you get the idea that "I'm loading images from the CDN but not as it should be" ... X3 simply isn't using the CDN ... because of the issue above.

Also, I think you are misinterpreting the issue with RELATIVE links. What the CDN77 technician is trying to point out, is that you simply are not loading the images from the CDN url. It doesn't matter in X3 if they are RELATIVE, for example "/path/image.jpg", or ABSOLUTE "gallery.kog.it/path/image.jpg" ... The technician is simply pointing out that you are not loading absolute from the CDN 77 url.

So here is a roundup -

1. CDN isn't working AT ALL from your X3. It's loading ALL images from local server.

2. It's not related to "relative" links. If we used absolute links in X3, it would be http://gallery.kog.it/path/image.jpg instead of /path/image.jpg. The PROBLEM is that the CDN URL isn't working for some reason, because then it would create paths CDN-url-here/path/image.jpg. Furthermore, this has nothing to do with the cache issue you have.

3. This issue is 100% UNRELATED to your initial request about why images don't get cached. First of all, X3 isn't even loading images from the CDN. All images are loaded from local server. Also, when/if we do get the CDN working, this issue is simply not related to Imagevue (clearly), because imagevue just outputs the images and it is up to your CDN to cache them long enough.
 
User avatar
mjau-mjau
X3 Wizard
Posts: 14469
Joined: 30 Sep 2006, 03:37

Re: Using a CDN

02 May 2016, 14:51

andreamarucci wrote:and you'll see that the first image has this url

<img src="/render/w480-q90/4.20112015/3.2013/1.130113/20130110_084821.jpg" style="height: 266px;" data-src="/render/w480-q90/4.20112015/3.2013/1.130113/20130110_084821.jpg" alt="20130110 084821" itemprop="thumbnail">

that's relative, so taken from my server.

But if you go at the same address using the CDN url, the same relative URL is "relative" to the CDN so the images are taken from the CDN.

The problem is only that IV is using relative URL so if I enter with my server URL, the images are taken from my server, if I enter with the CDN URL, are taken from the CDN...
You are putting too much into "relative" urls. The ONLY problem is that the CDN setting is not working. If it was working, it would add the CDN url in FRONT of the images, so you would get this:
Code
http://CDNURL/render/w480-q90/4.20112015/3.2013/1.130113/20130110_084821.jpg
It's not the issue itself that images are relative. The problem is that the CDN setting simply isn't applying.
 
User avatar
andreamarucci
Experienced
Topic Author
Posts: 312
Joined: 01 Mar 2011, 11:13

Re: Using a CDN

02 May 2016, 15:27

Ah ok I assumed that the CDN URL worked and that's why I wrote about relative url and so on. I'm sending you my admin credentials so you can check by yourself...

Thanks a lot!
 
User avatar
andreamarucci
Experienced
Topic Author
Posts: 312
Joined: 01 Mar 2011, 11:13

Re: Using a CDN

02 May 2016, 15:33

Sent the credentials now via PM. Thanks again. I'm very curious to know why isn't working :-)
 
User avatar
mjau-mjau
X3 Wizard
Posts: 14469
Joined: 30 Sep 2006, 03:37

Re: Using a CDN

03 May 2016, 00:45

There's a bug in X3.

It works when you refresh a page, but not when pages are navigated to from the menu. So you were in fact correct: it did work "sometimes", but only for the first page you load from the browser.

Hotfix
You can hotfix it, by editing templates/page.json, close to the top:
Code
{% set assetspath = page.settings.cdn|trim('/')|default(rootpath) %}
Change to:
Code
{% set assetspath = page.settings.cdn_files|trim('/')|default(rootpath) %}
First load will be slow, as X3 has to re-render the templates into PHP files. This fix is added to the pending release, available shortly.

PS! This fix has generally nothing to do with the CDN caching issue. Likely you will get more hits in general though, expired or not.
 
User avatar
andreamarucci
Experienced
Topic Author
Posts: 312
Joined: 01 Mar 2011, 11:13

Re: Using a CDN

03 May 2016, 07:46

mjau-mjau wrote:There's a bug in X3.
Thanks for pointing out Karl. I've applied the fix you've suggested and I'll let you know how it goes with the CDN...
 
User avatar
andreamarucci
Experienced
Topic Author
Posts: 312
Joined: 01 Mar 2011, 11:13

Re: Using a CDN

03 May 2016, 07:48

Based on some test I can confirm that now it works and all the images are from the CDN...

Thanks again!
 
User avatar
andreamarucci
Experienced
Topic Author
Posts: 312
Joined: 01 Mar 2011, 11:13

Re: Using a CDN

05 May 2016, 06:48

Hello Karl, as you may see the situation is better than before
Schermata 2016-05-05 alle 12.08.53.png
Schermata 2016-05-05 alle 12.08.53.png (39.92 KiB) Viewed 7911 times
but not as it should be.

Below you'll see the graph of my forum's CDN
Schermata 2016-05-05 alle 12.09.10.png
Schermata 2016-05-05 alle 12.09.10.png (36.41 KiB) Viewed 7911 times
where you can see that almost entirely the forum is cached.

There's something other I can do or I can check in IV?

Thanks!
 
User avatar
mjau-mjau
X3 Wizard
Posts: 14469
Joined: 30 Sep 2006, 03:37

Re: Using a CDN

05 May 2016, 11:39

andreamarucci wrote:Below you'll see the graph of my forum's CDN
Keep in mind one big difference. Your forum should reach 100% caching once all pages are visited once.

In X3 on the other hand, any grid layout page in X3, will serve an image depending on the screen size (decides how the grid breaks), retina and non-retina. Therefore, you could have NEW image requests way into the future when an irregular devices visits a page.

I'm not saying that is the reason, but Im just making you aware of some clear differences.
andreamarucci wrote:There's something other I can do or I can check in IV?
Let me make an example. Here is an image inside X3 content:
http://1041320869.rsc.cdn77.org/content ... 1201/2.jpg

Here are the headers from your CDN for this image:
Code
Date: Thu, 05 May 2016 14:26:50 GMT
Content-Type: image/jpeg
Content-Length: 115178
[b]Last-Modified: Mon, 13 Apr 2015 11:23:38 GMT[/b]
[b]Cache-Control: max-age=315360000[/b]
[b]Expires: Sun, 03 May 2026 14:25:10 GMT[/b]
Server: CDN77-Turbo
X-Edge-IP: 46.234.127.81
[b]X-Edge-Location: bratislavaSK
X-Cache: HIT[/b]
X-Age: 100
Accept-Ranges: bytes
Connection: keep-alive
Your original image, where the CDN pulls from, and inherits headers (unless overridden in your cdn77 settings):
http://gallery.kog.it/content/2.2001200 ... 1201/2.jpg

First of all, the X3 application doesn't "serve" that image. It's just requested from the server. You could DELETE the entire X3 application (except this image), and the image would still be exactly the same, with exactly the same headers (try if you want ...). Therefore, I am not sure how anyone can claim this has anything to do with X3.

See headers for the original image:
Code
Date: Thu, 05 May 2016 14:30:19 GMT
Server: Apache
[b]Last-Modified: Mon, 13 Apr 2015 11:23:38 GMT[/b]
Accept-Ranges: bytes
Content-Length: 115178
[b]Cache-Control: max-age=315360000[/b]
[b]Expires: Sun, 03 May 2026 14:30:19 GMT[/b]
Content-Type: image/jpeg
Connection: keep-alive
As you can see, the "expires" headers are clearly set, and correctly inherited into your CDN headers. Basically your CDN gets that image, and should base its caching on the "expires" date Expires: Sun, 03 May 2026 14:30:19 GMT ... This header is pretty clear, no? If your CDN has to re-request the image from origin prior to this date, then you need to ask the CDN provider.

I can only imagine this possible scenario: Ok so you have 1000s of images right? ... and then each image comes in 5-6 sizes that might be requested over time (based on devices and screens)? ... and then each of these images will steadily be "pulled" to the CDN network edge locations, based on when a visitor makes the request from a specific location? This means that it will take ages for ALL your images to successfully cache to ALL edge locations, as all images, need to get requested in all sizes from all locations.

To be honest, I am not 100% sure about the above, Im just trying to come up with a possible explanation. In either case, this is not X3's doing .. especially unless the experts at CDN77 can point out what's wrong. How can I be so sure? Because apart from the htaccess which sets headers, X3 doesn't (and can't) do anything to the image. The image headers are entirely correct, as you can see for yourself, and as CDN77 will have to admit also. You could delete the X3 app, and images/headers would be the same. Furthermore, once an image gets cached at CDN77, it should never get requested again from your server (x3), until 10 years later, as are clearly defined in the response headers ... So why does cdn77 re-request the image? Only they can answer that.