1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Cache Pages with APC / Mysql

Discussion in 'Server Configuration and Hosting' started by Marcus, Sep 27, 2012.

  1. Marcus

    Marcus Well-Known Member

    Usually when I first read a page at one browser (let's say Firefox) it is around 0.3 seconds for the page load. When accessing the page another time, the page load time is reduced to 0.04 seconds. I can also view the page as a guest on another browser like IE or Chrome and it will be loaded in 0.04 seconds.

    How is that possible? Is that because of APC? And why are all pages slow in the first attempt to load it - because other users also access the pages. And a once accessed page should stay in the APC cache. This is my APC cache statistics:

  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    If the compiled script was not previously in the APC cache then yes, that could explain the numbers you are seeing.
  3. Insy

    Insy Well-Known Member

  4. MattW

    MattW Well-Known Member

    Can you post your full APC settings? You are also on a fairly old version of APC. Latest is 3.1.13
  5. Marcus

    Marcus Well-Known Member

    Thats my apc.php
    ; Enable apc extension module
    extension = apc.so
    ; Options for the APC module version >= 3.1.3
    ; This can be set to 0 to disable APC.
    ; The number of shared memory segments to allocate for the compiler cache.
    ; The size of each shared memory segment in MB.
    ; A "hint" about the number of distinct source files that will be included or
    ; requested on your web server. Set to zero or omit if you're not sure;
    ; Just like num_files_hint, a "hint" about the number of distinct user cache
    ; variables to store. Set to zero or omit if you're not sure;
    ; The number of seconds a cache entry is allowed to idle in a slot in case this
    ; cache entry slot is needed by another entry.
    ; use the SAPI request start time for TTL
    ; The number of seconds a user cache entry is allowed to idle in a slot in case
    ; this cache entry slot is needed by another entry.
    ; The number of seconds that a cache entry may remain on the garbage-collection list.
    ; On by default, but can be set to off and used in conjunction with positive
    ; apc.filters so that files are only cached if matched by a positive filter.
    ; A comma-separated list of POSIX extended regular expressions.
    ; The mktemp-style file_mask to pass to the mmap module
    ; This file_update_protection setting puts a delay on caching brand new files.
    ; Setting this enables APC for the CLI version of PHP (Mostly for testing and debugging).
    ; Prevents large files from being cached
    ; Whether to stat the main script file and the fullpath includes.
    ; Vertification with ctime will avoid problems caused by programs such as svn or rsync by making
    ; sure inodes havn't changed since the last stat. APC will normally only check mtime.
    ; Whether to canonicalize paths in stat=0 mode or fall back to stat behaviour
    ; With write_lock enabled, only one process at a time will try to compile an
    ; uncached script while the other processes will run uncached
    ; Logs any scripts that were automatically excluded from being cached due to early/late binding issues.
    ; RFC1867 File Upload Progress hook handler
    apc.rfc1867_prefix =upload_
    ; Optimize include_once and require_once calls and avoid the expensive system calls used.
    ; not documented
  6. MattW

    MattW Well-Known Member

    If you don't change the files much, you could set

    I also set:

    to be

    as this stores the files in shared memory, and not on the disk.
    Marcus likes this.
  7. Mick West

    Mick West Well-Known Member

    If you do this then be aware that if you use the option "Fetch public templates as files", then template changes to cached templates will NOT take effect, including templates changed by the TMS.
  8. MattW

    MattW Well-Known Member

    Correct. That is why I said "if you don't change the files much". If you had that set, you can flush the APC cache when you make any changes and the new files will be cached again.

    Apologies if that wasn't very clear in my previous post.
  9. Mick West

    Mick West Well-Known Member

    I just didn't think of a template change done via the TMS as a file change. And it's not really, unless you have "Fetch public templates as files" set then it's a database change.

Share This Page