Home  >  Article  >  Backend Development  >  Apache cache related configuration_PHP tutorial

Apache cache related configuration_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:13:35822browse

Configuration example:

<span <</span><span IfModule </span><span mod_disk_cache.c</span><span ></span><span    
  CacheDefaultExpire 86400   
  CacheEnable disk /   
  CacheRoot /tmp/apacheCache   
  CacheDirLevels 5   
  CacheDirLength 5   
  CacheMaxFileSize 1048576   
  CacheMinFileSize 10   
</span><span </</span><span IfModule</span><span ></span>   

CacheDefaultExpire: Set the cache expiration time (seconds), the default is 1 hour, this command will only take effect when the cached document does not have an expiration time or last modification time set
CacheEnable: Enable caching. The first parameter is the cache type. The second parameter is the cache path, which refers to the url path. Here is the cache of everything. Simply write "/". For example, "/docs" only caches all files under /docs
CacheRoot: The directory where the cached files are located. The user running Apache (such as daemon or nobody) must be able to read it. Write, if you are not sure, you can directly set it to 777. Please create the directory manually and set the access permissions
CacheDirLevels: The depth of the cache directory, the default is 3, here it is set to 5
CacheDirLength: The character length of the cache directory name, the default is 4, here it is set to 5
CacheMaxFileSize and CacheMinFileSize: The maximum and minimum values ​​​​of cached files (bytes). When this range is exceeded, the cache will no longer be cached. Here it is set to 1M and 10bytes

<span <</span><span IfModule </span><span mod_mem_cache.c</span><span ></span><span    
  CacheEnable mem /   
  MCacheMaxObjectCount 20000   
  MCacheMaxObjectSize 1048576   
  MCacheMaxStreamingBuffer 65536   
  MCacheMinObjectSize 10   
  MCacheRemovalAlgorithm GDSF   
  MCacheSize 131072   
</span><span </</span><span IfModule</span><span ></span>  

CacheEnable: Enable caching and use memory-based storage
MCacheMaxObjectCount: The maximum number of cache objects that can be stored in memory, the default is 1009. The setting here is 20000
MCacheMaxObjectSize: The maximum size of a single cache object is 1M, the default is 10000 bytes
MCacheMaxStreamingBuffer: The maximum number of objects that can be placed in the buffer The size of the object to be cached is set here to 65536. This value is usually less than 100000 or the value set by MCacheMaxObjectSize
MCacheMinObjectSize: The minimum size of a single cache object is 10bytes, and the default is 1bytes
MCacheRemovalAlgorithm: The algorithm used to clear the cache. The default is GDSF, and the other is LRU. You can check Apache’s official documentation, which has some introductions

MCacheSize: The maximum memory that can be used for cached data, in kb, the default is 100kb, here it is set to 128M

#Cache content


http://www.bkjia.com/PHPjc/440348.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/440348.htmlTechArticleConfiguration example: CacheDefaultExpire: Set the cache expiration time (seconds), the default is 1 hour, only when cached This command only works when the document does not have an expiration time or last modified time...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn