PDA

View Full Version : Store library and plugin remotely via CDN



rosegarden
May 30, 2012, 10:12 PM
If I want to store my Library and plugin remotely thru a Content Delivery Network Services

Should i be changing this:

define( 'RL_LIBS', RL_ROOT . 'libs' . RL_DS );

or

define( 'RL_LIBS_URL', RL_URL_HOME . 'libs/' );

or both?


================================================== ======


// system paths
define( 'RL_DIR', '' );
define( 'RL_ROOT', '/home/xxxx/public_html' . RL_DS . RL_DIR );
define( 'RL_INC', RL_ROOT . 'includes' . RL_DS );
define( 'RL_CLASSES', RL_INC . 'classes' . RL_DS );
define( 'RL_CONTROL', RL_INC . 'controllers' . RL_DS );
define( 'RL_LIBS', RL_ROOT . 'libs' . RL_DS );
define( 'RL_TMP', RL_ROOT . 'tmp' . RL_DS );
define( 'RL_UPLOAD', RL_TMP . 'upload' . RL_DS );
define( 'RL_FILES', RL_ROOT . 'files' . RL_DS );
define( 'RL_PLUGINS', RL_ROOT . 'plugins' . RL_DS );
define( 'RL_CACHE', RL_TMP . 'cache_xxxxxx' . RL_DS );

// system URLs
define( 'RL_URL_HOME', 'http://www.xxxx.com/' );
define( 'RL_FILES_URL', RL_URL_HOME . 'files/' );
define( 'RL_LIBS_URL', RL_URL_HOME . 'libs/' );
define( 'RL_PLUGINS_URL', RL_URL_HOME . 'plugins/' );

Viktor
May 31, 2012, 06:14 AM
Hello Desmond Lim,

Yes needs some changes here. Path to files will be different and you should write new.
Let me know what a new location path for files from library?

Please upload files on this service (CDN) and send me path for it. I want to check it.

rosegarden
May 31, 2012, 12:47 PM
define( 'RL_URL_CND', 'http://cdn.xxxx.com/' );

define( 'RL_LIBS_URL', RL_URL_CDN . 'libs/' );
define( 'RL_PLUGINS_URL', RL_URL_CDN . 'plugins/' );


define( 'RL_ROOT_CDN', 'http://cdn.xxxx.com/ . RL_DS . RL_DIR );

define( 'RL_LIBS', RL_ROOT_CDN . 'libs' . RL_DS );
define( 'RL_PLUGINS', RL_ROOT_CDN . 'plugins' . RL_DS );


I will try on my side and implement if the above works, is it correct?

Viktor
June 4, 2012, 10:36 AM
Hello Desmond Lim,

Would you please explain me what files do you want to move on CDN? Also RL_ROOT_CDN no needs because same url with RL_URL_CND.

rosegarden
June 5, 2012, 12:13 AM
I want to the following folders insider lib to CDN

- Javascript
- Jquery
- Ajax

Also files from:

- CSS

I have not implement yet but following is a more critical problem that I am facing with the coupon. Coupon users are not updated in the coupon_user tables as a result the limited function is not working.

Coupon that limit to 1 use and be used multiple times. Can you please help to solve this first. A ticket has been issued already.

http://www.flynax.com/forum/showthread.php?327-Coupon-Code-problem&p=1405#post1405

Viktor
June 6, 2012, 06:25 AM
Hello Desmond Lim,

It's ok but Ajax files we should leave on your server.
Please upload css files on CDN and send me urls for it. I will try to connect this files in your site.

rosegarden
June 7, 2012, 12:28 AM
I have raised a ticket ORC-146539: CDN of CSS and Img as I do not wish to place my CDN link here.

I have set a CDN path for CSS and IMG (for that template) only

However this CDN path is subject to changes as it is not fixed yet. If possible, i hope you can just want to rough guide so that I can make the changes if the path changes in the future.

Each plugin has it own static CSS as well, is it possible to implement them as well.
I have a total of 9 CSS that is downloaded each time because of the plugins other the main CSS.

rosegarden
June 7, 2012, 12:30 AM
Alternatively, assume we already know which plugin we are going to use , can we combine all the CSS for those plugins + main CSS together into one single CSS instead of so many stream of download each time?

rosegarden
June 19, 2012, 07:47 AM
I try to modify the header.tpl by including the following but it does not seem to work correctly, any advice on that?

Basically what it does is it test whether the browser can accept gzipped and then send the gzipped version.

Any other suggestions?

====
file : header.tpl
Purpose : CDN both js and css
Sending gzipped version if supported

============



<script type="text/javascript">var sr_gzipEnabled = false;</script>
<script type="text/javascript" src="http://d2ft4b0ve1aur1.cloudfront.net/js-050/sr.gzipcheck.js.jgz"></script>

<noscript>
<link type="text/css" rel="stylesheet" href="http://xxxx.cloudfront.net/css/common.css">
</noscript>
<script type="text/javascript">
(function () {
var sr_css_file = 'http://xxxx.cloudfront.net/css/common.css';
if (sr_gzipEnabled) {
sr_css_file = 'http://xxxx.cloudfront.net/test/common.css.gz';
}

var head = document.getElementsByTagName("head")[0];
if (head) {
var scriptStyles = document.createElement("link");
scriptStyles.rel = "stylesheet";
scriptStyles.type = "text/css";
scriptStyles.href = sr_css_file;
head.appendChild(scriptStyles);
//alert('adding css to header:'+sr_css_file);
}
}());
</script>

Viktor
June 21, 2012, 05:00 AM
Hello Desmond Lim,


can we combine all the CSS for those plugins + main CSS together into one single CSS instead of so many stream of download each time?

Yes we can merge all css files in 1 file and upload on CDN server. about archived css file it's not important for now. Browser downloads the file only one time and then caches it.

I check your ticket right now.

rosegarden
June 21, 2012, 08:59 AM
I have solved the compressed file issue, just need to configure Amazon s3 setting ...

Only 1 question, I want to combine the follow plugin style to :

http://www.xxx.com/plugins/fieldBoundBoxes/static/style.css
http://www.xxx.com/plugins/comment/static/style.css
http://www.xxx.com/plugins/bookmarks/static/style.css

to one single style.css below

/public_html/templates/general_modern/css/style.css

I have copy all the following style into the above file. What is next? How can I ensure that these files are not loaded each time?

Viktor
June 22, 2012, 11:26 AM
Hello Desmond Lim,


I have copy all the following style into the above file. What is next? How can I ensure that these files are not loaded each time?

All browsers in last time is using cache system and css and images files load only once and then under the following loads browsers take images and css files from cache.
But if you change image or css file internet browser detect it and load it again it once.

For example in you load site in Safari browser and then change css files on your site and load your site again this browser load old css files from cache. and you should push ctrl+f5 for load new css files with your changes from server. That's why you shouldn't worry about it.

rosegarden
September 25, 2012, 10:45 PM
Sorry for bumping this old thread.

I am still able to merge all the css into one file

for example, I rename the style at fieldboundbox to style.css_bk ,

but there is still call a the style sheet for that plugin whenever i load the page and now it is 404 because that file is missing.

There is still call in the hook for the install.xml, how do i remove the calling from the hook?

================================================== =====================

<hook name="tplHeader"><![CDATA[
echo '<link href="'.RL_PLUGINS_URL.'fieldBoundBoxes/static/style.css" type="text/css" rel="stylesheet" />';
]]></hook>

Mike
September 26, 2012, 04:45 AM
Hello Desmond,

Hook is the code of plugin which is stored in the database and then executed when necessary for that plugin. To deactivate the code you have to set hook status to inactive (approval)
or remove it completely from the database.

For the hooks which load css files, all of them should be with name tplHeader.

So open your database through phpmyadmin for example and go to manage fl_hooks table.

Find entries with Name=tplHeader Plugin=fieldBoundBox

But in the hooks can be another code and if you disable it it may break something.
So better maybe just remove <link tag which loads style.css