plugins - cakephp asset management speed -


i'm new cakephp , found in manual:

it’s known fact serving assets through php guaranteed slower serving assets without invoking php. , while core team has taken steps make plugin , theme asset serving fast possible, there may situations more performance required. in these situations it’s recommended either symlink or copy out plugin/theme assets directories in app/webroot paths matching used cakephp.

app/plugin/debugkit/webroot/js/my_file.js     becomes app/webroot/debug_kit/js/my_file.js app/view/themed/navy/webroot/css/navy.css     becomes app/webroot/theme/navy/css/navy.css 

are files in plugin/webroot/asset required read php inserted html rather served directly server because isn't webroot directory can accessed http module?

the manual says soft links speed process up. cakephp first in /app/webroot/asset call dispatcher find in plugin/webroot/asset , read , serve it?

or process identical in how file found/read except cake must use dispatcher locate asset if not in app/webroot/asset location?

for serving files...

webservers fastest

the default rewrite rules follows:

rewritecond %{request_filename} !-f rewriterule ^ index.php [l] 

that means if request file webserver can see - don't talk php respond file's contents (or appropriate headers). in circumstance there no "does cakephp first in /app/webroot/asset ..." there no cakephp - or php - involved in handling request @ all.

so, in brief that's:

request  -> webserver    -> check if file exists     -> response (file contents) 

if different webserver (not apache) being used, cakephp expects equivalent rewrite rules. never check if equivalent of app/webroot/<the current url> exists - webserver should doing itself.

php slow

if request file not exist in webroot, things slower because quite there's more processes involved. php script so:

<?php // example app/webroot/index.php $path = 'server/this/file.html'; echo file_get_contents($path); exit; 

is slower equivalent request handled directly webserver, that's:

request  -> webserver    -> check if file exists     -> invoke php        -> file contents      -> respond webserver    -> response 

plus php wasn't designed serving files (like webserver or should be) , inherently slower webserver alone @ doing so.

cakephp slower

the path directly web-accessible cakephp project ´app/webroot`.

for request handled cakephp, using asset dispatch filter (which slimmed down dispatch process) - there more logic involved, it's slower bare minimum logic required server file php. in brief request becomes:

request  -> webserver    -> check if file exists     -> invoke php        -> bootstrap cakephp       -> dispatch request         -> check dispatch filters           -> check if request matches configured plugin/theme file path             -> check if file exists           -> generate response         -> output response     -> respond webserver    -> response 

the difference in performance compared letting webserver handle request static file can significant.

conclusion

serving files php when it's not necessary waste of resources, if @ possible allow response come higher request - webserver, proxy or preferably user's own browser cache (~0 latency!).


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -