Magento Expert Forum - Improve your Magento experience

Results 1 to 2 of 2

How to configuring APC cache for Magento?

  1. #1
    Administrator david's Avatar
    Join Date
    Nov 2012
    Posts
    261
    Thanks
    22
    Thanked 42 Times in 34 Posts

    Default How to configuring APC cache for Magento?

    APC (Alternative PHP cache) is a free opcode cache for PHP, which optimize PHP intermediate code. APC engine cache the compiled bytecode of PHP scripts to avoid the overhead of parsing and compiling source code on each request.Magento stores its cache data in the file system by default. This is fine for small sites with low traffic. As you get more and more traffic and HTTP requests, file system reading and writing will become slower.The APC PHP module will not speed up the Magento itself, its eliminates the delay caused by having to parse Magento PHP files code on every HTTP request. It is recommend to use APC on production servers for Magento optimization.If you use Firebug Net panel in your browser, you can measure Magento page generation time before and after APC cache activation:Installation of APC on your server

    Nowadays all modern hosting providers support a variety of PHP cache engines including APC cache. You can ask your hosting support to install APC module for you. If you have a dedicated server, you can install APC yourself.The PHP APC is PECL module, and should be installed in your system as any PECL module for PHP, more details is here.Recommended APC configuration for Magento

    By default APC configuration is not adjusted for Magento. In some cases you will see fatal errors in server logs, e.g. “PHP Fatal error: Cannot redeclare class”. To fix such errors you need to change default APC configuration in PHP.INI file or APC.INI (depending on your configuration).Here are recommended APC settings for Magento Community and Enterprise:
    In case of using APC bytecode cache, the modification time check option (apc.stat) must be disabled.Notice: sometimes you will meet problem with PHP code (wodpress admin for example), in this case let ‘s change this configurationapc.include_once_override=0Activate APC support in Magento configuration

    In order to activate APC support in Magento core, you should modify /app/etc/local.xml configuration file.
    Add these lines between GLOBAL tags:

    The “Prefix” value is a short descriptor that will allow you to use APC caching for several Magento stores on the same server, it should be unique for each Magento store you have.If you want to enabled 2 level cache for your Magento, you can use slow_backend tag in local.xml.Magento has two levels cache: a fast level and a slow level cache. Magento will use the fast level if possible, and if there is no memory available in APC, it will revert to the slow level cache. It will eliminate any down time connected with cache memory issues.You can define “database” or “file” values for slow_backend:
    Save local.xml and test Magento storefront. If you will notice any errors, make sure that local.xml was modified correctly.How to check if APC is working correctly?

    First of all you should notice that Magento PHP scripts become faster. Use Firebug Net panel to measure Magento load time, as it described in the beginning of this article. You can download Firebug extension for Firefox here.Next, you can download special APC.php script that will show APC usage statistics, such as memory usage, uptime, number of successfully cached queries (Hits & Misses), etc. You can also clear APC cache using this script.APC.php script could be downloaded from official PECL APC website: http://pecl.php.net/package/apcDownload the latest stable APC archive, open it and upload /apc-X.X.XX/apc.php script to your WWW folder. Next, visit apc.php using your browser.You can also download this script directly from SVN repository: http://svn.php.net/viewvc/pecl/apc/t...c.php?view=logDon’t forget to protect apc.php script using your own password. You can change APC password directly in the apc.php code using any text editor.Here is screenshot of APC statistics that you will see after script uploading and execution in your browser:

    The APC is powerful and stable cache engine, it is one of most popular PHP optimization tools that improve performance on high loaded websites and widely used with Magento.
    source: http://magentohostsolution.com/confi...cache-magento/

    View more threads in the same category:


  2. #2
    Junior Member phuc2x's Avatar
    Join Date
    Mar 2013
    Posts
    16
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Default

    Very good help, work for me. Thanks

Similar Threads

  1. Move Magento Cache to RAM by tmpfs
    By david in forum Magento Speed up, Performance and Optimize
    Replies: 4
    Last Post: 13-06-2016, 12:19 PM
  2. Adding Cache Support to Magento Blocks
    By sgdev in forum Magento Speed up, Performance and Optimize
    Replies: 2
    Last Post: 29-05-2014, 10:47 AM
  3. Magento Cache strategy for best performance
    By david in forum Magento Speed up, Performance and Optimize
    Replies: 3
    Last Post: 29-05-2014, 08:10 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •