If you're using Apache, you can use mod_rewrite to statically cache your web pages. Lets say you're using PHP, and you have a request for "/somepage.php". In your .htaccess file you put the following:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^$ # let's not cache urls with queries
RewriteCond %{REQUEST_METHOD} ^GET$ # or POST/PUT/DELETE requests
RewriteCond static_cache/%{REQUEST_URI} -s # Check that this file exists and is > 0 bytes
RewriteRule (^.*$) static_cache$1 [L] # If all the conditions are met, we rewrite this request to hit the static cache instead
If your cache turns up empty, the request is handled by your php script as usual, so now it's simply a matter of making your php script store the resulting html in the cache. The simplest way to do this is using another htaccess rule to prepend end append a couple of php files to all your php requests (this might or might not be a good idea, depending on your application):
php_value auto_prepend_file "pre_cache.php"
php_value auto_append_file "post_cache.php"
Then you'd do something like this:
pre_cache.php:
ob_start();
post_cache.php:
$result = ob_get_flush();
if(!$_SERVER['QUERY_STRING']) { # Again, we're not caching query string requests
file_put_contents("static_cache/" + __FILE__, $result);
}
With some additional regular expressions in the .htaccess file we could probably start caching query string requests as well, but I'll leave that as an exercise for the reader :)