<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Apache Corporation &#8211; stoimen&#039;s web log</title>
	<atom:link href="/tag/apache-corporation/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>on web development</description>
	<lastBuildDate>Tue, 13 Feb 2018 08:18:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.0.3</generator>
	<item>
		<title>Diving into Node.js &#8211; Introduction &#038; Installation</title>
		<link>/2010/11/16/diving-into-node-js-introduction-and-installation/</link>
		<comments>/2010/11/16/diving-into-node-js-introduction-and-installation/#comments</comments>
		<pubDate>Tue, 16 Nov 2010 08:17:32 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[Apache Corporation]]></category>
		<category><![CDATA[Apache HTTP Server]]></category>
		<category><![CDATA[application/server]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[classical chat server]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Google Chrome]]></category>
		<category><![CDATA[Google Inc.]]></category>
		<category><![CDATA[Inter-process communication]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[JavaScript programming language]]></category>
		<category><![CDATA[Node.js]]></category>
		<category><![CDATA[normal server]]></category>
		<category><![CDATA[normal web server]]></category>
		<category><![CDATA[operating system]]></category>
		<category><![CDATA[Push technology]]></category>
		<category><![CDATA[Server-side JavaScript]]></category>
		<category><![CDATA[Software engineering]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[typical web server]]></category>
		<category><![CDATA[Web browser]]></category>
		<category><![CDATA[web developer team]]></category>
		<category><![CDATA[web server]]></category>
		<category><![CDATA[web server example]]></category>
		<category><![CDATA[web serving functionality]]></category>
		<category><![CDATA[World Wide Web]]></category>

		<guid isPermaLink="false">/?p=2037</guid>
		<description><![CDATA[Why I Need Something Like Node.js? First of all the use of some software is needed not because of itself, but because of the need of some specific functionality. In my case this was the need of real time news feed. Of course there is a way to make this without Node.js, as I&#8217;ll describe &#8230; <a href="/2010/11/16/diving-into-node-js-introduction-and-installation/" class="more-link">Continue reading <span class="screen-reader-text">Diving into Node.js &#8211; Introduction &#038; Installation</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/12/02/diving-into-node-js-a-long-polling-example/" rel="bookmark" title="Diving into Node.js &#8211; A Long Polling Example">Diving into Node.js &#8211; A Long Polling Example </a></li>
<li><a href="/2010/11/19/diving-into-node-js-very-first-app/" rel="bookmark" title="Diving into Node.js &#8211; Very First App">Diving into Node.js &#8211; Very First App </a></li>
<li><a href="/2010/01/31/speed-up-the-javascript-it-can-change-dramatically-the-user-experience/" rel="bookmark" title="Speed up the JavaScript. It can change dramatically the user experience.">Speed up the JavaScript. It can change dramatically the user experience. </a></li>
<li><a href="/2010/01/11/what-should-be-optimized-in-one-web-page/" rel="bookmark" title="What should be optimized in one web page?">What should be optimized in one web page? </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Why I Need Something Like Node.js?</h2>
<p>First of all the use of some software is needed not because of itself, but because of the need of some specific functionality. In my case this was the need of real time news feed. Of course there is a way to make this without <a title="Node.js" href="http://nodejs.org/" target="_blank">Node.js</a>, as I&#8217;ll describe later in this post, but there are several disadvantages. However to begin from somewhere, let me explain what is Node.js.</p>
<h2>Introducing Node.js</h2>
<p>Perhaps the best way do describe what is Node.js is from its <a title="Node.js" href="http://nodejs.org/#about" target="_blank">about page</a>.</p>
<blockquote><p>Node&#8217;s goal is to provide an easy way to build scalable network programs. In the &#8220;hello world&#8221; web server example above, many client connections can be handled concurrently. Node tells the operating system (through epoll, kqueue, /dev/poll, or select) that it should be notified when a new connection is made, and then it goes to sleep. If someone new connects, then it executes the callback. Each connection is only a small heap allocation.</p>
<p>&#8230;</p></blockquote>
<p>In general Node is a program using the Google Chrome&#8217;s <a title="V8 JavaScript engine" href="http://code.google.com/p/v8/" target="_blank">V8 JavaScript</a> engine, which in turn is a program that can parse and execute code written in JavaScript. V8 is a very very interesting project itself. First of all from Google have developed this engine especially for one of his products &#8211; their browser <a title="Google Chrome" href="http://www.google.com/chrome" target="_blank">Chrome</a>. It pretends to be and by no means is one of the masterpieces of Google. It is fast and reliable engine, written in C++ and JavaScript, as <a title="V8 JavaScript engine on Wikipedia" href="http://en.wikipedia.org/wiki/V8_%28JavaScript_engine%29" target="_blank">Wikipedia&#8217;s page</a> says. Actually this code is open source and can be embedded in whatever application written in C++. Thus you can have in your application a JavaScript engine.<span id="more-2037"></span></p>
<p>Such kind of application/server is Node.js. With V8 embedded into, Node is intended to run on a machine and to serve some requests. Just like a normal web server, but with few differences. First of all Node is not only serving HTTP requests, but also TCP. Well I&#8217;m not so deep into this yet, but so far that works for me. What I need for now is its web serving functionality.</p>
<p>The way Node works, however is different from what we know from every other web server. Here it is a normal server in general:</p>
<p><a href="/wp-content/uploads/2010/11/client-server.png"></a><a href="/wp-content/uploads/2010/11/client-server.png"><img class="alignleft size-full wp-image-2053" title="client-server" src="/wp-content/uploads/2010/11/client-server.png" alt="Client Server" width="600" height="150" srcset="/wp-content/uploads/2010/11/client-server.png 600w, /wp-content/uploads/2010/11/client-server-300x75.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></a></p>
<p>Whenever a request comes to the server, it tries to return the response as fast as possible. This is one of the main goals of every web developer team &#8211; to make the application as fast as possible. However in Node the things work different:</p>
<p><a href="/wp-content/uploads/2010/11/node-client-server.png"><img class="alignleft size-full wp-image-2058" title="node-client-server" src="/wp-content/uploads/2010/11/node-client-server.png" alt="Node.js Client Server Application" width="600" height="150" srcset="/wp-content/uploads/2010/11/node-client-server.png 600w, /wp-content/uploads/2010/11/node-client-server-300x75.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></a></p>
<p>Here the server doesn&#8217;t return immediately the response, but holds as long as possible until some &#8220;event&#8221; occurs. You can thing of Node as a classical chat server. Until one of the peers doesn&#8217;t write a message, the other doesn&#8217;t receive anything.</p>
<blockquote><p>Some may be confused as how you can use both the typical web server, as Apache, with Node as another web server within the same page. The answer is &#8211; with AJAX. As you know thus you can have only one chunk of your page talking with the server &#8211; in this case the entire page is returned by Apache, but inside the page you can have a chat app using Node as a server, working perhaps on a different port on the same machine.</p></blockquote>
<p>Typically this scenario can be simulated without Node, but as I said, with some disadvantages. Let&#8217;s say you have two browsers and one server &#8211; you can infinitely loop AJAX calls to the server and whenever there is new message on the server return it to the browser &#8211; this is quite inefficient. There are two approaches in this case.</p>
<ol>
<li>You can make those AJAX calls too recently and you can have a call every N seconds. In that case if N is to short you&#8217;ll have too many calls and in case the other peer doesn&#8217;t make anything the server will be unusually loaded with no practical effect.</li>
<li>In the second case you can choose to make N too long &#8211; for instance 20 seconds. This is also bad, because during this period of time the peers may want to interact and chat.</li>
</ol>
<p>In that case Node is a web server, but simply doesn&#8217;t return the response until a specific event doesn&#8217;t occur. How does this look like in a web browser. You may know how looking into the <a title="Firebug" href="https://addons.mozilla.org/en-US/firefox/addon/1843/" target="_blank">Firebug console</a> for every AJAX call you see the request and how many seconds it has taken. If you make an AJAX call to a Node server app the request just doesn&#8217;t respond immediately.</p>
<h2>Installing Node.js</h2>
<p>The process of installation is <a title="Node.js Build" href="http://nodejs.org/#build" target="_blank">described quite well</a>, so I&#8217;m going to describe it in few steps.</p>
<ol>
<li>Download the application from Git, note that V8 is embedded inside. The version while this post was written and of course was stable is <a title="Node.js v0.2.4" href="http://nodejs.org/dist/node-v0.2.4.tar.gz" target="_blank">v0.2.4</a></li>
<li>For those familiar with Unix/Linux systems, there are three simple steps following, however without <a title="Gnu Compiler Collection" href="http://gcc.gnu.org/" target="_blank">GCC (Gnu Compiler Collection)</a> you wont be able to proceed! I&#8217;m writing this especially for the Mac OS users, as they may know there is no built-in GCC there.</li>
<li>./configure</li>
<li>make</li>
<li>make install</li>
<li>make test (optional)</li>
</ol>
<p>This in general is enough. After all that you can write the node command in your terminal. However if there are some problems while compiling it you may refer to Git and the Node community for more help. Don&#8217;t forget that V8 can work only on x86, x64 and ARM architectures.</p>
<h2>Summary</h2>
<p>There are few things that can be summarized now:</p>
<ol>
<li>First of all Node can be a web server, as Apache is, but with the option to respond on event firing.</li>
<li>You can request it either with a web page loaded in your browser or within a chunk of the page via AJAX.</li>
<li>To install Node you need GCC. It comes with V8 JavaScript engine inside, which can run only on x86, x64 and ARM.</li>
</ol>
<p>So far so good! Now we have Node installed, practically useless, because there is no application running on it. In my next post I&#8217;ll describe how to run your first application.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/12/02/diving-into-node-js-a-long-polling-example/" rel="bookmark" title="Diving into Node.js &#8211; A Long Polling Example">Diving into Node.js &#8211; A Long Polling Example </a></li>
<li><a href="/2010/11/19/diving-into-node-js-very-first-app/" rel="bookmark" title="Diving into Node.js &#8211; Very First App">Diving into Node.js &#8211; Very First App </a></li>
<li><a href="/2010/01/31/speed-up-the-javascript-it-can-change-dramatically-the-user-experience/" rel="bookmark" title="Speed up the JavaScript. It can change dramatically the user experience.">Speed up the JavaScript. It can change dramatically the user experience. </a></li>
<li><a href="/2010/01/11/what-should-be-optimized-in-one-web-page/" rel="bookmark" title="What should be optimized in one web page?">What should be optimized in one web page? </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/11/16/diving-into-node-js-introduction-and-installation/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to Overcome Zend_Cache_Frontend_Page&#8217;s Problem with Cookies</title>
		<link>/2010/11/03/how-to-overcome-zend_cache_frontend_pages-problem-with-cookies/</link>
		<comments>/2010/11/03/how-to-overcome-zend_cache_frontend_pages-problem-with-cookies/#comments</comments>
		<pubDate>Wed, 03 Nov 2010 14:19:25 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[Apache Corporation]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[Computer memory]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[CPU cache]]></category>
		<category><![CDATA[Cross-platform software]]></category>
		<category><![CDATA[database server]]></category>
		<category><![CDATA[Google Inc.]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[HTTP cookie]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[MySQL Americas Inc.]]></category>
		<category><![CDATA[Page cache]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[script interpreter]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[web app]]></category>
		<category><![CDATA[web application caching]]></category>
		<category><![CDATA[Web application frameworks]]></category>
		<category><![CDATA[web server]]></category>
		<category><![CDATA[Zend Technologies]]></category>

		<guid isPermaLink="false">/?p=2024</guid>
		<description><![CDATA[Zend_Cache_Frontend_Page First of all there are several things to know about Zend Framework and caching. Whenever you work on a big web application caching is one of the mostly used mechanisms of speeding up the app and improve user performance. In general the task and the solution are pretty simple and natural. As the application &#8230; <a href="/2010/11/03/how-to-overcome-zend_cache_frontend_pages-problem-with-cookies/" class="more-link">Continue reading <span class="screen-reader-text">How to Overcome Zend_Cache_Frontend_Page&#8217;s Problem with Cookies</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2011/01/17/a-memcached-zend_cache/" rel="bookmark" title="A Memcached Zend_Cache">A Memcached Zend_Cache </a></li>
<li><a href="/2010/01/27/theory-of-caching-zend_cache-zend-optimizer/" rel="bookmark" title="Theory of caching. Zend_Cache &#038; Zend Optimizer.">Theory of caching. Zend_Cache &#038; Zend Optimizer. </a></li>
<li><a href="/2010/07/21/setting-up-global-cache-in-zend-framework/" rel="bookmark" title="Setting Up Global Cache in Zend Framework">Setting Up Global Cache in Zend Framework </a></li>
<li><a href="/2010/07/19/zend-framework-cache-database-table-schemes/" rel="bookmark" title="Zend Framework: Cache Database Table Schemes">Zend Framework: Cache Database Table Schemes </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Zend_Cache_Frontend_Page</h2>
<p>First of all there are several things to know about Zend Framework and caching. Whenever you work on a big web application caching is one of the mostly used mechanisms of speeding up the app and improve user performance. In general the task and the solution are pretty simple and natural.</p>
<p>As the application grows up the visitors become more and more impatient about what they receive. A single page is becoming slower and slower and the result is painful. First of all every time a user hits a page the application server uses the web server, a script interpreter, a database server and potentially the file system. But that&#8217;s not all. After all this output is generated on the server, as HTML in the most cases, it is sent to the client where again CSS and JavaScript engines parse and execute them.</p>
<p>In this scenario it&#8217;s easy to imagine how many time is spent. While there are several techniques to optimize the client side by optimizing JavaScript, CSS and the static images used for the design of the site, here I&#8217;m going to talk more about the backend.</p>
<h2>Beside the Optimization</h2>
<p>Let&#8217;s assume we&#8217;ve one of the very used combination between Apache (as a webserver), PHP (as server scripting language) and MySQL (as database server). Here you can choose to optimize all three of them. However beside the optimization of them one of the most simple steps you can do is to cache the output generated by these three branches of your web app.</p>
<h2>Caching the Content</h2>
<p>In fact you can cache only single parts of the whole process. For instance you can cache only the result returned by some slow database query. Let&#8217;s imagine a query takes about 2 seconds to execute. Now you can cache the result into a file and during the cache is active, i.e. it has not expired, the application takes it from a file stored somewhere in the file system.</p>
<p>In a typical Zend Framework scenario you can first setup the frontend and backend options of the cache.</p>
<pre lang="php">
$frontendOptions = array(
	'lifetime'                => 600, // in seconds - this is 10 seconds
	'automatic_serialization' => true,
);
$backendOptions = array('cache_dir' => 'cache/');
$cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
		
$cacheKey = md5('mykey');

if (!$cache->load($cacheKey)) {
	$slowQueryResult = $article->fetchAll();
	$cache->save($slowQueryResult, $cacheKey);
} else {
	$slowQueryResult = $cache->load($cacheKey);
}
</pre>
<p>You can setup different options here by setting up the cache directory, lifetime, etc.</p>
<p><em>Note that the cache directory must exists and with write permissions and Zend Framework doesn&#8217;t create it for you and will throw error.</em></p>
<p>The problem here is that now you cache only part of the generated content and in many cases this is still too slow for most of the users. However all the work (in most of the cases) of the web server, the script interpreter and the database server result in a simple HTML output. What if you have this output generated or cached for you and when the user hit the page the server will return this pre-generated code?</p>
<p>This is indeed very fast, because it&#8217;s similar to return a text file, as the HTML is simply formatted text.</p>
<h2>Caching the Entire Page</h2>
<p>Before I proceed, I&#8217;d like to say that I work with Zend Framework 1.9.x. Now in the latest versions of ZF there are new mechanisms of caching the output even Zend_Cache_Frontend_Page works fine on them.</p>
<p>You can simply setup the page cache within few simple lines of code:</p>
<pre lang="php">
$fo = array(
    'lifetime' => 600,
    'regexps' => array(
        '^/' => array(
	'cache' => true,
         'cache_with_cookie_variables' => true,
        ),
    )
);

$bo = array(
    'cache_dir' => 'cache/'
);

$cache = Zend_Cache::factory('Page', 'File', $fo, $bo);
$cache->start();
</pre>
<p>However my advise is to place this code as high as possible, because this will cache everything generated as output. It&#8217;s a good practice if you place this even in the bootstrap before you make the connection with the database. Actually you don&#8217;t need a database connection when you&#8217;ve to return a simple text(html) file.</p>
<p>This will improve your app&#8217;s performance a lot!</p>
<p>However there are few things to know. When you setup the cache to work even with cookie variables, you can see that hitting the page with different browsers Zend Framework will generated different cache pages. This is quite useless because than you don&#8217;t have any benefit of caching the content.</p>
<p>First of all let me say that THIS IS NOT A BUG! of ZF. Simply the framework will use the cookie variables to generate the cache key. It&#8217;s obvious that different browsers, even more different users, will have different cookie set and the framework will generate different cache keys for them.</p>
<p>Thus you&#8217;ve to change the setting to generate the cache key from cookie variable by explicitly set this option to false:</p>
<pre lang="php">
$fo = array(
    'lifetime' => 600,
    'regexps' => array(
        '^/' => array(
		 'cache' => true,
         'cache_with_cookie_variables' => true,
         'make_id_with_cookie_variables' => false,
        ),
    )
);

$bo = array(
    'cache_dir' => 'cache/'
);

$cache = Zend_Cache::factory('Page', 'File', $fo, $bo);
$cache->start();
</pre>
<p>Note that in this example we cache every single page generated by the framework explained in the regexps. This is not so good especially when the users have the possibility to login and to see customized content for them, so you can be careful what you cache.</p>
<p>A typical problem that this solution solves is when your application uses Google Analytics. As you may know Google Analytics sets up a cookie every time when an user hits the page, so every time the framework will generate a different cache for him and in result he won&#8217;t see any benefit and performance improvement from your site.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2011/01/17/a-memcached-zend_cache/" rel="bookmark" title="A Memcached Zend_Cache">A Memcached Zend_Cache </a></li>
<li><a href="/2010/01/27/theory-of-caching-zend_cache-zend-optimizer/" rel="bookmark" title="Theory of caching. Zend_Cache &#038; Zend Optimizer.">Theory of caching. Zend_Cache &#038; Zend Optimizer. </a></li>
<li><a href="/2010/07/21/setting-up-global-cache-in-zend-framework/" rel="bookmark" title="Setting Up Global Cache in Zend Framework">Setting Up Global Cache in Zend Framework </a></li>
<li><a href="/2010/07/19/zend-framework-cache-database-table-schemes/" rel="bookmark" title="Zend Framework: Cache Database Table Schemes">Zend Framework: Cache Database Table Schemes </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/11/03/how-to-overcome-zend_cache_frontend_pages-problem-with-cookies/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
