Search…

X3 Photo Gallery Support Forums

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

Using a CDN

28 Apr 2016, 12:37

Hello Karl, I've a question for you.

I'm using a CDN with my gallery and everything is set correctly so I don't understand why the vast majority of my traffic is not cached. The images and galleries are always the same and sometimes I add a new gallery so why that? Have you an explanation? Maybe is how IV is done or something like that?
cdnkog.png
cdnkog.png (98.03 KiB) Viewed 6058 times
Thank you very much for your time
 
User avatar
mjau-mjau
X3 Wizard
Posts: 14008
Joined: 30 Sep 2006, 03:37

Re: Using a CDN

28 Apr 2016, 13:38

Who is the CDN provider? I had a similar issue with maxCDN more than a year ago. They never managed to solve it, so I cancelled ... Cloudflare works just as well anyway.

Seems some CDN providers have problems, and/or are not respecting cache headers. Have you set your CDN to "respect headers"? Seems they are flushing the cache way too early. The only thing that can affect images in X3, is the .htaccess file ... In the .htaccess, we set 10 year expiration for images, so they cache almost forever. The headers in image files output on websites with the X3 htaccess are entirely correct:

Example:
http://gallery.kog.it/content/5.2016202 ... C_0087.jpg
Cache-Control:max-age=315360000
Connection:Keep-Alive
Date:Thu, 28 Apr 2016 17:28:01 GMT
Expires:Sun, 26 Apr 2026 17:28:01 GMT
Keep-Alive:timeout=5, max=100
Server:Apache

See the above headers? That is the only headers for your images. Expiration is set to 10 years. You need to ask your CDN provider, because there is nothing more X3 is doing with images.

There is no difference in resized images either:
http://gallery.kog.it/render/w640-q90/5 ... C_0087.jpg
 
User avatar
andreamarucci
Experienced
Topic Author
Posts: 308
Joined: 01 Mar 2011, 11:13

Re: Using a CDN

29 Apr 2016, 10:35

I'm using CDN77 in this case... I understand what you mean so I'll ask them what happen...
 
User avatar
alexhenes
Experienced
Posts: 568
Joined: 28 Sep 2006, 16:13

Re: Using a CDN

30 Apr 2016, 14:54

Hey Karl...

I just signed up for the free CloudFlare account. Do you have an recommendations on CloudFlare settings. Some of the ones that come to mind are:

1. Speed.Auto Minify: I don't have any of these set... but it seems like it would be good to check JavaScript, CSS and HTML
2. Speed.Caching Level: Standard
3. Browser Cache Expiration: Given that I almost never change pages once they are posted... I am thinking I can set this to a relatively high value. However I don't want this to impact new content that I post... ie. I want new content to be available immediately.

Any guidance on these or any other CloudFlare settings would be appreciated.

Thanks
Alex
https://www.merelyafleshwound.com
https://www.goldenbikeshop.com
 
User avatar
GGANG
Experienced
Posts: 122
Joined: 02 Feb 2012, 11:01

Re: Using a CDN

30 Apr 2016, 16:02

Hi Alexhenes

TUTORIAL: Extreme Page caching with Cloudflare
https://forum.photo.gallery/viewtopic.p ... les#p37474
 
User avatar
alexhenes
Experienced
Posts: 568
Joined: 28 Sep 2006, 16:13

Re: Using a CDN

30 Apr 2016, 16:15

Sweet.... Thanks!
Alex
https://www.merelyafleshwound.com
https://www.goldenbikeshop.com
 
User avatar
GGANG
Experienced
Posts: 122
Joined: 02 Feb 2012, 11:01

Re: Using a CDN

30 Apr 2016, 16:23

Page Rules { CloudFlare Update April 2016 }
pagerule-panel.jpg
pagerule-panel.jpg (37.3 KiB) Viewed 6008 times
pagerule.jpg
pagerule.jpg (42.38 KiB) Viewed 6008 times
 
User avatar
mjau-mjau
X3 Wizard
Posts: 14008
Joined: 30 Sep 2006, 03:37

Re: Using a CDN

01 May 2016, 02:13

alexhenes wrote:I just signed up for the free CloudFlare account. Do you have an recommendations on CloudFlare settings. Some of the ones that come to mind are:
Just a quick general tip: Unless you are using the special "Extreme Page caching with Cloudflare" as suggested by @GGANG, you should keep Cloudflare settings default/minimal. Cloudflare will essentialy only do two things to your website:

1) Add basic CDN capabilities to static assets (image files)
2) Adds an external layer of protection from certain bots.

Cloudflare, unless using the "Extreme Page caching", will not have any effect on creation time of pages from X3 or even outputting cached pages from X3. Everything still needs to "render" from your server, and cloudflare simply does not cache "pages". Furthermore, most of the additional settings in Cloudflare have no effect in X3, simply because these features are already optimized in X3.
1. Speed.Auto Minify: I don't have any of these set... but it seems like it would be good to check JavaScript, CSS and HTML
All html, css and js in X3 is already minified, so this is not necessary. Furthermore, most of the CSS+JS are loaded from external CDN resources anyway, already minified. It wouldn't really make a difference if you keep it on or off, but it is not required.
2. Speed.Caching Level: Standard
Doesn't make a difference, because X3 does not operate with query strings. Also this setting only affects cacheable items, which in your case is images. The headers in X3 image files are set to 10 years, so Cloudflare MAY cache the images inevitably on their edge servers ...
3. Browser Cache Expiration: Given that I almost never change pages once they are posted... I am thinking I can set this to a relatively high value. However I don't want this to impact new content that I post... ie. I want new content to be available immediately.
Same as above, doesn't make a difference. Browser cache does not apply for "pages", so new content will always be visible, loaded from your server. X3 uses it's own dynamic server cache to determine if it should output a cached page, or has to recreate a new one ... In either case, it always comes from server. This setting ONLY affects static files (images). X3 already has 10 year caching on image files, which will be passed through to the visitors browser.
 
User avatar
andreamarucci
Experienced
Topic Author
Posts: 308
Joined: 01 Mar 2011, 11:13

Re: Using a CDN

01 May 2016, 05:35

Asked to cdn77 they've told me to reduce the number of the server used to the two main one. I've done as suggested so I'll see the results in the next few days and I'll let you know...
 
User avatar
mjau-mjau
X3 Wizard
Posts: 14008
Joined: 30 Sep 2006, 03:37

Re: Using a CDN

01 May 2016, 09:40

andreamarucci wrote:Asked to cdn77 they've told me to reduce the number of the server used to the two main one.
Not quite sure what that means ... You mean subdomains?

I am a bit curious ... I see no evidence that your images are output from CDN77 ... Don't they add something to the response headers like other CDN services? I am not saying the service is not working, but I find it strange that they don't add some headers to images that explain they are served from cdn77, and if the request is HIT or MISS. Here is a response header for an image from your website, which is just the default inherited from your own server:
http://gallery.kog.it/content/2.2001200 ... 0901/1.jpg
Accept-Ranges:bytes
Cache-Control:max-age=315360000
Connection:Keep-Alive
Content-Length:74308
Content-Type:image/jpeg
Date:Sun, 01 May 2016 13:33:48 GMT
Expires:Wed, 29 Apr 2026 13:33:48 GMT
Keep-Alive:timeout=5, max=100
Last-Modified:Mon, 13 Apr 2015 11:23:26 GMT
Server:Apache
With Cloudflare, and maxcdn, it outputs additional parameters which 1) confirms that the file is output from the CDN service, and 2) tell if the file was cached on the specific edge location (HIT), or if it is expired and needs to be pulled from origin server (MISS):
https://demo.photo.gallery/content/2.ga ... rctica.jpg
cache-control:public, max-age=315360000
cf-cache-status:HIT
cf-ray:29c39d87e903082f-SIN
date:Sun, 01 May 2016 13:35:12 GMT
expires:Wed, 29 Apr 2026 13:35:12 GMT
last-modified:Tue, 12 Apr 2016 19:03:57 GMT
server:cloudflare-nginx
status:304
vary:Accept-Encoding
Response headers are quite useful to check if a specific image is cached on the CDN or not. You could for example check the response headers of a single image every day ... Except for the first request, it should return HIT always (unless you purged CDN cache). You can view response headers in browser DEV TOOLS.
 
User avatar
alexhenes
Experienced
Posts: 568
Joined: 28 Sep 2006, 16:13

Re: Using a CDN

01 May 2016, 12:58

Thanks for the guidance on this. It has made a measurable difference for www.merelyafleshwound.com
Alex
https://www.merelyafleshwound.com
https://www.goldenbikeshop.com
 
User avatar
mjau-mjau
X3 Wizard
Posts: 14008
Joined: 30 Sep 2006, 03:37

Re: Using a CDN

01 May 2016, 13:10

alexhenes wrote:Thanks for the guidance on this. It has made a measurable difference for http://www.merelyafleshwound.com
Yep, that's pretty cool. Basically your pages (html/json) are now served lightning fast as static fragments from the Cloudflare network, and there is no processing involved.

Keep in mind, when you make "changes" on your website again, the processing will still need to happen from your server ... menu and pages will need to get recreated from scratch, and you will need to empty your Cloudflare page cache. Did you setup the Cloudflare panel add-on, so you can easily purge the Cloudflare cache when you make future changes to your website? You should.
Image

With all these levels of caching, you need to keep a keen eye on things so you are not left wondering "Hey I updated my page, but I can't see any changes on the website".

Keep in mind, the coming release next week should speed up performance from your website perhaps 4-500% ... That is the processing time required when you actually make changes, prior to cloudflare caching.
 
User avatar
andreamarucci
Experienced
Topic Author
Posts: 308
Joined: 01 Mar 2011, 11:13

Re: Using a CDN

02 May 2016, 10:05

mjau-mjau wrote:
andreamarucci wrote:Asked to cdn77 they've told me to reduce the number of the server used to the two main one.
Not quite sure what that means ... You mean subdomains?
I means the datacenter used as you may see here. I've told them to look at your reply since I really don't understand where is the problem...
Schermata 2016-05-02 alle 16.04.14.png
Schermata 2016-05-02 alle 16.04.14.png (29.03 KiB) Viewed 5972 times
 
User avatar
andreamarucci
Experienced
Topic Author
Posts: 308
Joined: 01 Mar 2011, 11:13

Re: Using a CDN

02 May 2016, 11:58

Karl it seems that the problem is related to the IV configuration since the wite, WP based, and the forum (Xenforo based) work without problems.

Here's the reply from the CDN77 techician.

Can you tell me what can I do to solve this?

Hello Andrea,

Regarding behavior mentioned by the developer in the forum. I have checked your site and the issue is, that your gallery use relative paths for the images, so when the album itself is accessed using the domain "gallery.kog.it" all the images in the album are loaded from your origin, when accessed using the CDN URL "1041320869.rsc.cdn77.org" all of the files are loaded using our CDN. Since most of the times you access the gallery using the "gallery.kog.it" domain, it is true, that you don't use our CDN service fully.
I have taken a look at the logs of the traffic on your resource and I can see that the most of the requests come from your "forum.kog.it", where it looks you have integrated everything correctly and the images are loaded using our CDN URL.

Regarding the caching of your files itself. The main issues is, that you have really a very large number of images and with not enough traffic accessing them.

So, please take a look at the issue with the integration, make sure that you use absolute paths using the CDN URL for your images on the "gallery.kog.it" domain. This could increase the traffic you will have on the CDN and subsequently improve the HIT / MISS ratio.
 
User avatar
andreamarucci
Experienced
Topic Author
Posts: 308
Joined: 01 Mar 2011, 11:13

Re: Using a CDN

02 May 2016, 12:01

Karl an idea. Maybe I can configure the DNS so that when you type "gallery.kog.it" it goes on "1041320869.rsc.cdn77.org". Do you think it's a good solution?