first, what is dynamic language static
1, the existing PHP and other dynamic language logic code into a static HTML file, the user access to dynamic script redirection to the static HTML file process;
2, the implementation of the requirements of the page, only to do dynamic language static;
second, why to static
1, the dynamic script will usually do logical calculation and data query, the greater the amount of traffic, the greater the server pressure;
2, the heavy traffic may cause the CPU load is too high, the database server pressure is too large;
3, static can reduce the logic processing pressure, reduce the database server query pressure
Third, the realization mode of static
Smarty:
$smarty->cache_dir = $ROOT. " cache/"; Cache directory
$smarty->caching = true; whether to turn on caching
$smarty->cache_lifetime = ' 3600 '; cache time: unit is seconds
$smarty->display () load template
$smarty->clear_all_cache () clears all caches
$smarty->clear_cache (' file.html ') clears the specified cache
$smarty->clear_cache (' a.html ', $id) clears the cache of the specified cache number under the same template;
ob function:
ob_start () Open output control buffer
ob_get_ontents () returns the contents of the output buffer
ob_clear () empty buffer
Ob_end_flush () flushes out buffer contents and turns off buffering
you can determine the inode modification time of a file and determine whether it expires with Filectime ()
Example:
Dynamic language static