পৃষ্ঠাসমূহ

.

Search Your Article

Total Pageviews

Monday, February 20, 2017

Grav - Performance & Caching

Performance

The term performance refers to the system performance in such a way that whether it can handle higher load on system and modify the system to handle a higher load.
Grav contains some key points of performance such as:

  • To have better performance of Grav, you can use PHP opcache and usercache. The opcache works well with PHP 5.4 and usercache works faster with PHP 5.5, PHP 5.6 and Zend opcache.
  • The SSD (Solid State Drive) which uses flash memory and has no moving parts. Sometimes cache will be stored in user cache or stored as files. So SSD drives can give better performance.
  • Virtual machines are the best way of hosting providers under cloud computing technology. You can specify the resources without interacting with physical equipment. The Native hosting is faster than virtual machine. Grav runs better on virtual machine, but for optimal performance you can make use of native hosting option.
  • Grav has faster memory in which its cache uses heavy memory that provides better performance on your server. Compared to other platforms, it uses less amount of memory.
  • Grav uses shared hosting on the shared server to share the things. Sharing hosting is available in a low cost and sometimes it may lead to slow the things on the server.
  • Multi core processors are used for handling multiple tasks faster. The advanced processors are better than these processors which helps the user to accomplish the task.

Caching

In general, cache is a stored data in a cache memory. Cache mechanism makes grav faster in which browser can get files from cache rather than the original server, saving time and additional network traffic.
Grav uses Doctrine Cache library which supports the following:
  • Auto (Default): It uses default option automatically.
  • File: It specifies cache files present in the cache/ folder.
  • APC
  • XCache
  • Memcache
  • Redis
  • WinCache
By default, Grav uses the auto setting. It will try for APC, then for WinCache, XCache and lastly it uses File.

Caching Types

There are 5 types of caching:
  • YAML configuration caching into PHP.
  • Core Grav caching for page objects.
  • Twig caching of template files as PHP classes.
  • Image caching for media resources.
  • Asset caching of CSS and jQuery with pipelining.
The caching of YAML configuration stored in the /cache folder. The image caching stores its images in the /images folder. The configuration option for core Grav caching is stored in user/config/system.yml file as shown below:
cache:
  enabled: true
  check:
    method: file
  driver: auto
  prefix: 'g'
  • The enabled option enables the caching by setting it to true.
  • The method option checks for the updates in pages such as files or folder.
  • The driver option specifies different types of caching options such as Auto, File, APC, XCache, Memcache, Redis or WinCache.
  • The prefix option defines cache prefix string.

Memcache Options

If you are using memcached server, then you need to add some extra configuration options by using memcache driver in the user/config/system.yml file. These options can be defined under cache: group.
cache:
...
...
   memcache:
    server:localhost
 port: 8080

Redis Options

If you are using redis, then you need to add some extra configuration options by using redis driver in the user/config/system.yml file. These options can be defined under cache: group.
cache:
...
...
   redis:
    server:localhost
 port: 8080
The Twig template uses its own caching mechanism by using twig driver in the user/config/system.yml file.
twig:
  cache: true
  debug: true
  auto_reload: true
  autoescape: false
It has some options such as:
  • cache option enables the twig caching by setting it to true.
  • debug option enables the twig debug.
  • auto_reload option is used to reload the changes by setting it to true.
  • autoescape option is used to auto escape the twig variables.

Caching and Events

Events can be used when caching is enabled. This can be enabled for all events except for OnPageContentRaw, OnPageProcessed, OnPageContentProcessed, OnTwigPageVariables and OnFolderProcessed events. These events can be used on all pages and folders and can run only when the events are processing. These events cannot be run after the page has been cached.

No comments:

Post a Comment