XF 2.0 Best way to handle CDN configuration in XF2?

Mike Fara

Active member
Hello fellow XF2 people, mods, and devs. In the past, for CDN usage, we used something in config.php like:

Code:
$config['javaScriptUrl'] = 'https://cdn.whatever.com/js';
$config['externalDataUrl'] = 'https://cdn.whatever.com/data';
Is this still supported? Clearly not, as data and js no longer exist. What would be the proper usage now, if any? Thank you in advance.
 

Mike Fara

Active member
Hi @Brogan

Basically, I moved out the old config.php in favor of the new one in XF2. If you're saying those lines of code variables can still be used, I will give it a try. I read the manual and I'm uncertain if theres additional assets that can be moved to the CDN using additional variables. Perhaps I am mistaken. Also, not to go off topic (but I will), we use PHP 7.0's Zend Opcache. Does this need to be set as a parameter such as

Code:
$config['cache']['enabled'] = true;$config['cache']['frontend'] = 'Core';
$config['cache']['frontendOptions']['cache_id_prefix'] = 'xf_';
$config['cache']['cacheSessions'] = false;
Or is front-end cache presumed on by default in this version? Sorry for the confusion and thanks for your reply.
 

Mike Fara

Active member
Thank you. Would you recommend running memcached with Zend Opcache already enabled in PHP7 or do you think this is overkill? Mind you Im using Litespeed and not nginx. Sorry for the 20 questions here.
 

Brogan

XenForo moderator
Staff member
For larger installations, it can be worth implementing caching to save on queries and processing time.

If you do decide to implement session caching then Memcached is the one we would recommend.
 

Mike Fara

Active member
For larger installations, it can be worth implementing caching to save on queries and processing time.

If you do decide to implement session caching then Memcached is the one we would recommend.
Hmm yes, Litespeedtech had a great plugin for 1.x to use their cache engine, but at present time, it looks like they are working on a rewrite for XF2. Perhaps running memcache wouldn't add too much overhead, so thanks for that reply.

Here is another one, and I promise, this will probably be the last one:

Even though the external data URL is set to our CDN, and is working for avatars, I cannot help but notice that XF Media Gallery images are still referrencing /media and attachments are still being pulled locally. Is there something in the style editor that needs to be altered? We also use htaccess rewrites to try to catch all images, but it doesn't look like it is 100% effective right now. This makes me think that the path to attachments may be explicitly defined somewhere in the default XenForo styles as I believe it may have been in 1.x. Do you know where I would alter the attachment path (and possibly XenForo media gallery path) in the default XenForo theme, or is there some other mechanism to fix this?

For example, avatars and header images will point to the CDN, but attachments and media gallery images do not. I can only conclude that this is something defined in the actual style.

For example, an attached image will look something like this in the HTML (example):

Code:
<img class="lg-object lg-image" src="https://xenforum.com/attachments/win10-mike-july-png.30428/">
Similarly, non-image attachments appear in the HTML like this (example):

Code:
<a href="/attachments/w7f_16-12-2017-zip.35593/" target="_blank" title="W7F_16-12-2017.zip">W7F_16-12-2017.zip</a>
And finally, media gallery images appear in the HTML as (example):

Code:
<img src="/media/pups-image-jpg.717/full" class="js-mediaImage">
They are not pointing to, for instance, cdn.xenforo.com. Not sure what the solution is for this?

Thank you.
 

Sperber

Well-known member
@Brogan ,
I´m trying to get keycdn to work with XF 2 and I just can´t find, where the image path is located in XF2. Could you help me over the street, please? ;)
 

mcatze

Well-known member
Just insert in config.php..
PHP:
$config['externalDataUrl'] = "https://cdn.domain.com/data";
$config['javaScriptUrl'] = "https://cdn.domain.com/js";
 

Miguel Dias

Member
Hmm yes, Litespeedtech had a great plugin for 1.x to use their cache engine, but at present time, it looks like they are working on a rewrite for XF2. Perhaps running memcache wouldn't add too much overhead, so thanks for that reply.

Here is another one, and I promise, this will probably be the last one:

Even though the external data URL is set to our CDN, and is working for avatars, I cannot help but notice that XF Media Gallery images are still referrencing /media and attachments are still being pulled locally. Is there something in the style editor that needs to be altered? We also use htaccess rewrites to try to catch all images, but it doesn't look like it is 100% effective right now. This makes me think that the path to attachments may be explicitly defined somewhere in the default XenForo styles as I believe it may have been in 1.x. Do you know where I would alter the attachment path (and possibly XenForo media gallery path) in the default XenForo theme, or is there some other mechanism to fix this?

For example, avatars and header images will point to the CDN, but attachments and media gallery images do not. I can only conclude that this is something defined in the actual style.

For example, an attached image will look something like this in the HTML (example):

Code:
<img class="lg-object lg-image" src="https://xenforum.com/attachments/win10-mike-july-png.30428/">
Similarly, non-image attachments appear in the HTML like this (example):

Code:
<a href="/attachments/w7f_16-12-2017-zip.35593/" target="_blank" title="W7F_16-12-2017.zip">W7F_16-12-2017.zip</a>
And finally, media gallery images appear in the HTML as (example):

Code:
<img src="/media/pups-image-jpg.717/full" class="js-mediaImage">
They are not pointing to, for instance, cdn.xenforo.com. Not sure what the solution is for this?

Thank you.

Same here, trying to set cdn but only avatars and thumbs are served...
 
Top