Server application program cache

Apache for Web Server Server

  1. Apache’s expiration module mod_Expires. So

Control HTTP’s “Expires:” and “Cache-Control:” headers via configuration files

# Enable Expires_Module LoadModule Expires_Module modules/ mod_Expires. So # Enable Expires_Module modules/ mod_Expires. 2592000 seconds for a month ExpiresByType image/GIF A2592000 # HTML document is valid for a week after the last modified time ExpiresByType text/HTML M604800 # under the similar meaning ExpiresByType text/css "now plus 2 months" ExpiresByType image/jpeg "access plus 2 months"

ExpiresByType image/jpeg “access plus 2 months” expiresByType image/jpeg expiresByType image/jpeg “access plus 2 months” expiresByType image/jpeg expiresByType image/jpeg “access plus 2 months” expiresByType image/jpeg expiresByType image/jpeg The MIME type ACCESS of A specific file means that the expiration time is calculated from the time of access, which is equivalent to the NOW and A parameters. It can also be set to the Modification or M parameter, which means that the last modification time of the accessed file starts to be calculated. Months means months, and available parameters include: years, months, weeks, days, hours, minutes, seconds

  1. Apache’s caching module mod_cache
  • Mod_cache: A URI key-based dynamic content caching module that caches the response header and body so that it can be quickly matched on the next request.

    • Mod_disk_cache (Apache2.2)/mod_cache_disk (Apache2.4) Disk-based caching module
    • Mod_mem_cache. so (Apache2.2) Memory based caching module, removed from version 2.4
  • Mod_file_cache provides file descriptor cache support, which speeds up file access to slow file system servers. Only static files can be used.

PHP’s APC and Opcache

  • Opcache is a way to avoid the overhead of loading and parsing a PHP script each time it is parsed by storing the pre-compiled bytecode of the PHP script in shared memory.
  • The parser can read the cached bytecode directly from the shared memory, greatly improving the performance of PHP.
  • APC is a framework for caching and optimizing PHP intermediate code and can cache Opcodes.
  • After PHP 5.5, Zend Opcache was integrated into PHP and can be used instead of APC. This feature is turned off by default.

How to use Opcache?

  1. Visit a phpinfo (); Page, Loaded Configuration File => /etc/php.7.0/fpm /php.ini and Scan this dir for additional. INI Files => /etc/php.7.0/fpm /conf.d
  2. See zend_extension = opcache. So whether open: vim/etc/PHP / 7.0 / FPM/conf. D / 10 – opcache. Ini (default is open)

PHP Execution Procedure

  • Check the lexing
<? php $source = <<<EOT <? php echo '1111'; EOT; print_r(token_get_all($source));

MySQL Query Cache

There are two parameter Settings associated with query caching:

  1. QUERY_CACHE_SIZE query cache size, which defaults to 16M
  2. QUERY_CACHE_TYPE has three values available. 0 means that the query cache is not used, 1 means that all results are cached, 2 means that SQL Cache is used in the SELECT statement to cache the results of the query, and no value is available if the SQL Cache is not used.

Sets the configuration related to the query cache

  1. Go to the main configuration file to see sudo vim /etc/mysql/my.cnf
  2. Enter configuration file sudo vim/etc/mysql/mysql. Conf. D/mysqld. CNF
QUERY_CACHE_TYPE = 1 // Enable the query cache. By default, it is not enabled. You need to add this line manually
  1. Sudo service mysql restart mysql restart
  2. Mysql > mysql -u root -p mysql -u root -p
  3. Show variables like “%query_cache%”;
  4. Show status like “%Qcache%”;

MySQL Memory Engine

Principle:

Engine = MEMORY is used to create the table structure. The table structure is stored on disk
.frmIn the file, after the server starts, this structure is used to create an empty table in memory, using the hash index by default.

Advantages:

  1. It is faster than MyISAM and InnoDB storage engines and is suitable for front-facing hot table caching.
  2. The SQL operation is consistent with the storage engine.

Points of use:

  1. Variable length types such as VARCHAR are converted to fixed length
  2. Before MySQL 4.1.0, AUTO_INCREMENT columns were not supported
  3. You cannot contain BLOB or TEXT columns
  4. Loss of restart data, if there is a backup, will result in data inconsistent with the backup
  5. The memory table data is larger than the max_heap_table_size set value, and the data exceeds the set value will be stored on disk
  6. Scalability and concurrent processing of mixed writes are poor at high loads

The original address