It works for phpBB 3.1.x, not just phpBB 3.1.6. For a national forum or global forum, it is a must to have a CDN support.
The way I used is not a formal extension or plugin. It is a hack, actually a dirty hack. If you have no experience for it, you can close this page now.
Now, let’s start.
- Backup everything of your phpBB, include files and database.\
- URL path example.
Forum url is http://www.myforum.com/
CDN url is http://myforum.kxcdn.com/ - Open /includes/functions.php
add following in line 5112// Add CDN path
$cdn_cache
=
'//myforum.kxcdn.com/'
;
Find following around Line 5216
'T_ASSETS_PATH'
=>
"{$web_path}assets"
,
'T_THEME_PATH'
=>
"{$web_path}styles/"
. rawurlencode(
$user
->style[
'style_path'
]) .
'/theme'
,
'T_TEMPLATE_PATH'
=>
"{$web_path}styles/"
. rawurlencode(
$user
->style[
'style_path'
]) .
'/template'
,
Replace by
'T_ASSETS_PATH'
=>
$cdn_cache
.
"assets"
,
'T_THEME_PATH'
=>
$cdn_cache
.
"styles/"
. rawurlencode(
$user
->style[
'style_path'
]) .
'/theme'
,
'T_TEMPLATE_PATH'
=>
$cdn_cache
.
"styles/"
. rawurlencode(
$user
->style[
'style_path'
]) .
'/template'
,
Find following around Line 5230
'T_STYLESHEET_LINK'
=>
"{$web_path}styles/"
. rawurlencode(
$user
->style[
'style_path'
]) .
'/theme/stylesheet.css?assets_version='
.
$config
[
'assets_version'
],
'T_STYLESHEET_LANG_LINK'
=>
"{$web_path}styles/"
. rawurlencode(
$user
->style[
'style_path'
]) .
'/theme/'
.
$user
->lang_name .
'/stylesheet.css?assets_version='
.
$config
[
'assets_version'
],
Replace by
'T_STYLESHEET_LINK'
=>
$cdn_cache
.
"styles/"
. rawurlencode(
$user
->style[
'style_path'
]) .
'/theme/stylesheet.css?assets_version='
.
$config
[
'assets_version'
],
'T_STYLESHEET_LANG_LINK'
=>
$cdn_cache
.
"styles/"
. rawurlencode(
$user
->style[
'style_path'
]) .
'/theme/'
.
$user
->lang_name .
'/stylesheet.css?assets_version='
.
$config
[
'assets_version'
],
Save and overwrite the original file.
- Open /includes/functions_content.php
Find following around Line 902return
preg_replace(
'#<!\-\- s(.*?) \-\-><img src="\{SMILIES_PATH\}\/(.*?) \/><!\-\- s\1 \-\->#'
,
'<img class="smilies" src="'
.
$root_path
.
$config
[
'smilies_path'
] .
'/\2 />'
,
$text
);
Replace by
return
preg_replace(
'#<!\-\- s(.*?) \-\-><img src="\{SMILIES_PATH\}\/(.*?) \/><!\-\- s\1 \-\->#'
,
'<img class="smilies" src="'
.
'//forum.kxcdn.com/forum/'
.
$root_path
.
$config
[
'smilies_path'
] .
'/\2 />'
,
$text
);
Save and overwrite the old file.
- Then purge cache in the ACP.
Look at the waterfall chat after this hack.
The CDN service provider is KEYCDN. You can apply through this link.