MyWebsite: Example 7: Sending partial files and the Not Modified header

I recommend you to download the source code of this example and to follow the description here looking also at the sources, in order to follow better the descriptions.

CLICK HERE TO DOWNLOAD THE SOURCE CODE

As you probably know, the HTTP protocol has built-in features to reduce the HTTP traffic. Some of these features are used automatically by Saetta Web Server, for example the HTTP compression can be enabled by the XML configuration file and be used automatically with SAAPIs when serving web pages. Continue reading

MyWebsite: Example 6: Atomic operations

I recommend you to download the source code of this example and to follow the description here looking also at the sources, in order to follow better the descriptions.

CLICK HERE TO DOWNLOAD THE SOURCE CODE

If you read the article Atomic operations in PHP with Saetta Web Server you know that in PHP it’s possible to exploit the function saetta_memcache_item_mathop exported to all PHP scripts by Saetta Web Server with PHP support to perform atomic operations on PHP integer variables via memcache. Continue reading

MyWebsite: Example 5: Databases everywhere (PostgreSQL)

I recommend you to download the source code of this example and to follow the description here looking also at the sources, in order to follow better the descriptions.

CLICK HERE TO DOWNLOAD THE SOURCE CODE

In the previous examples an important point has been skipped, and now it’s time to explain it better.

Where to save structures such as my_thread_data_t, when the function api.connection_thread_userdata_get is not available? Continue reading

MyWebsite: Example 4: Reading from a DBMS (PostgreSQL) and caching read values.

I recommend you to download the source code of this example and to follow the description here looking also at the sources, in order to follow better the descriptions.

CLICK HERE TO DOWNLOAD THE SOURCE CODE

In the previous example a couple of points have been more or less skipped, and now it’s time to explain them better.

  • How to cache read data with memcache
  • How to restore lost connections to the DBMS

In this example the function to print the table of all registered users used in the previous example is analyzed better and extended. Continue reading

MyWebsite: Example 3: Connecting to a DBMS (PostgreSQL)

I recommend you to download the source code of this example and to follow the description here looking also at the sources, in order to follow better the descriptions.

CLICK HERE TO DOWNLOAD THE SOURCE CODE

Things are turning more interesting in this example. When you create a server-side dynamic web page you connect often to a database. Databases introduce latencies and their usage isn’t free. A connection to a database requires time, memory and CPU time. However, it’s often just not possible not to rely on a database.

Using databases with Saetta Web Server gives some advantages. Continue reading

MyWebsite: Example 2: Using Memcache

I recommend you to download the source code of this example and to follow the description here looking also at the sources, in order to follow better the descriptions.

CLICK HERE TO DOWNLOAD THE SOURCE CODE

This example will be apparently useless, but it’s going to explain you how to use the caching component of Saetta Web Server, memcache (not to be confused with the much slower memcached daemon of third parties). Continue reading

MyWebsite: Example 1: The first SAAPI

I recommend you to download the source code of this example and to follow the description here looking also at the sources, in order to follow better the descriptions.

CLICK HERE TO DOWNLOAD THE SOURCE CODE

In the source package you’ll find various files. The most relevant are demo.xml and demo.c

The XML file is the configuration file. You can feed Saetta Web Server with this file in order to make the website in this example working. The .c file is the source code of the SAAPI (as global filter) in the C programming language. Continue reading

Atomic operations in PHP with Saetta Web Server

This article will show you (with examples) the usage of the function saetta_memcache_item_mathop exported to all PHP scripts by Saetta Web Server with PHP support.

The original idea behind that function is to atomically perform a mathematical operation on a PHP variable. That variable is saved in the memory caching subsystem of Saetta Server. And thus, in order to have this example working, you’ve to enable the memory caching system of Saetta Server. Read the article named “Memory caching with Saetta Server” on this blog to know more about the memory caching feature of all Saetta Servers. Continue reading