Welcome to Centmin Mod Community
Register Now

Weird issue with Cache Enabler

Discussion in 'Blogs & CMS usage' started by Jay Chen, Sep 18, 2018.

  1. Jay Chen

    Jay Chen Member

    54
    11
    8
    Sep 10, 2017
    Ratings:
    +21
    Local Time:
    1:28 AM
    Hi all,

    anyone noticed an issue with cache enabler where it is serving the cached version to logged in user?

    I tried clearing the cache, but cached version is still being served.
    This only happens with the pages that I visited.

    For example, I visited page 1, then I made a change to the php file, reload page 1, I don't see the new changes, because a cached version is served. But if I visit page 2, I will see the changes.

    I have no clue how this is happening.
     
  2. eva2000

    eva2000 Administrator Staff Member

    36,333
    7,979
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,287
    Local Time:
    3:28 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    maybe looking at wrong cache for php edits, zend opcache defaults come into play requiring a php-fpm restart within 180 seconds of php edits

    You can customise your Zend Opcache settings yourself in their own .ini settings file as outlined at centminmod.com/phpfpm.html#customphpini. You might want to create /etc/centminmod/php.d/b_customphp.ini to override centmin mod defaults at /etc/centminmod/php.d/a_customphp.ini and restart PHP-FPM. Also outlined in Getting Started Guide Step 17

    list of all default Centmin Mod .ini settings files via command php --ini
    Code (Text):
    php --ini
    Configuration File (php.ini) Path: /usr/local/lib
    Loaded Configuration File:         /usr/local/lib/php.ini
    Scan for additional .ini files in: /etc/centminmod/php.d
    Additional .ini files parsed:      /etc/centminmod/php.d/a_customphp.ini,
    /etc/centminmod/php.d/curlcainfo.ini,
    /etc/centminmod/php.d/geoip.ini,
    /etc/centminmod/php.d/igbinary.ini,
    /etc/centminmod/php.d/imagick.ini,
    /etc/centminmod/php.d/mailparse.ini,
    /etc/centminmod/php.d/memcache.ini,
    /etc/centminmod/php.d/memcached.ini,
    /etc/centminmod/php.d/redis.ini,
    /etc/centminmod/php.d/zendopcache.ini
    

    Zend Opcache settings are set in /etc/centminmod/php.d/zendopcache.ini. So to override them create a new .ini file that is alphabetically ordered after zendopcache.ini to override any settings in /etc/centminmod/php.d/zendopcache.ini i.e. /etc/centminmod/php.d/zzz-zendopcache.ini
    Code (Text):
    php --ini
    Configuration File (php.ini) Path: /usr/local/lib
    Loaded Configuration File:         /usr/local/lib/php.ini
    Scan for additional .ini files in: /etc/centminmod/php.d
    Additional .ini files parsed:      /etc/centminmod/php.d/a_customphp.ini,
    /etc/centminmod/php.d/curlcainfo.ini,
    /etc/centminmod/php.d/geoip.ini,
    /etc/centminmod/php.d/igbinary.ini,
    /etc/centminmod/php.d/imagick.ini,
    /etc/centminmod/php.d/mailparse.ini,
    /etc/centminmod/php.d/memcache.ini,
    /etc/centminmod/php.d/memcached.ini,
    /etc/centminmod/php.d/redis.ini,
    /etc/centminmod/php.d/zendopcache.ini,
    /etc/centminmod/php.d/zzz-zendopcache.ini
    

    be sure to restart php after making changes
    Code (Text):
    service php-fpm restart
    

    or cmd shortcut
    Code (Text):
    fpmrestart
    

    To check current Zend Opcache settings
    Code (Text):
    php --ri "Zend Opcache"
    

    example output which shows both local and master value (global values which usually are the same)
    Code (Text):
    php --ri "Zend Opcache"
    
    Zend OPcache
    
    Opcode Caching => Disabled
    Optimization => Disabled
    SHM Cache => Enabled
    File Cache => Disabled
    Startup Failed => Opcode Caching is disabled for CLI
    
    Directive => Local Value => Master Value
    opcache.enable => On => On
    opcache.use_cwd => On => On
    opcache.validate_timestamps => On => On
    opcache.validate_permission => Off => Off
    opcache.validate_root => Off => Off
    opcache.inherited_hack => On => On
    opcache.dups_fix => Off => Off
    opcache.revalidate_path => Off => Off
    opcache.log_verbosity_level => 1 => 1
    opcache.memory_consumption => 496 => 496
    opcache.interned_strings_buffer => 16 => 16
    opcache.max_accelerated_files => 65407 => 65407
    opcache.max_wasted_percentage => 5 => 5
    opcache.consistency_checks => 0 => 0
    opcache.force_restart_timeout => 180 => 180
    opcache.revalidate_freq => 180 => 180
    opcache.file_update_protection => 2 => 2
    opcache.preferred_memory_model => no value => no value
    opcache.blacklist_filename => no value => no value
    opcache.max_file_size => 0 => 0
    opcache.protect_memory => 0 => 0
    opcache.save_comments => 1 => 1
    opcache.fast_shutdown => 0 => 0
    opcache.optimization_level => 0x7FFFBFFF => 0x7FFFBFFF
    opcache.opt_debug_level => 0 => 0
    opcache.enable_file_override => On => On
    opcache.enable_cli => Off => Off
    opcache.error_log => no value => no value
    opcache.restrict_api => no value => no value
    opcache.lockfile_path => /tmp => /tmp
    opcache.file_cache => no value => no value
    opcache.file_cache_only => 0 => 0
    opcache.file_cache_consistency_checks => 1 => 1
    opcache.huge_code_pages => On => On
    
     
  3. eva2000

    eva2000 Administrator Staff Member

    36,333
    7,979
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,287
    Local Time:
    3:28 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    If the file is php then yes caching could be Zend Opcache related, the default revalidate frequency is 180 seconds
    Code (Text):
    php --ri 'Zend OPcache'
    
    Zend OPcache
    
    Opcode Caching => Disabled
    Optimization => Disabled
    SHM Cache => Enabled
    File Cache => Disabled
    Startup Failed => Opcode Caching is disabled for CLI
    
    Directive => Local Value => Master Value
    opcache.enable => On => On
    opcache.use_cwd => On => On
    opcache.validate_timestamps => On => On
    opcache.inherited_hack => On => On
    opcache.dups_fix => Off => Off
    opcache.revalidate_path => Off => Off
    opcache.log_verbosity_level => 1 => 1
    opcache.memory_consumption => 64 => 64
    opcache.interned_strings_buffer => 8 => 8
    opcache.max_accelerated_files => 8000 => 8000
    opcache.max_wasted_percentage => 5 => 5
    opcache.consistency_checks => 0 => 0
    opcache.force_restart_timeout => 180 => 180
    opcache.revalidate_freq => 180 => 180
    opcache.file_update_protection => 2 => 2
    opcache.preferred_memory_model => no value => no value
    opcache.blacklist_filename => no value => no value
    opcache.max_file_size => 0 => 0
    opcache.protect_memory => 0 => 0
    opcache.save_comments => 1 => 1
    opcache.fast_shutdown => 1 => 1
    opcache.optimization_level => 0x7FFFBFFF => 0x7FFFBFFF
    opcache.enable_file_override => On => On
    opcache.enable_cli => Off => Off
    opcache.error_log => no value => no value
    opcache.restrict_api => no value => no value
    opcache.lockfile_path => /tmp => /tmp
    opcache.file_cache => no value => no value
    opcache.file_cache_only => 0 => 0
    opcache.file_cache_consistency_checks => 1 => 1
    opcache.huge_code_pages => Off => Off


    To customise Zend Opcache settings see the instructions to create your own .ini settings file to retain the changes at https://centminmod.com/phpfpm.html#customphpini

    Example order of php .ini files applied via php --ini command
    Code (Text):
    php --ini
    Configuration File (php.ini) Path: /usr/local/lib
    Loaded Configuration File:         /usr/local/lib/php.ini
    Scan for additional .ini files in: /etc/centminmod/php.d
    Additional .ini files parsed:      /etc/centminmod/php.d/a_customphp.ini,
    /etc/centminmod/php.d/curlcainfo.ini,
    /etc/centminmod/php.d/geoip.ini,
    /etc/centminmod/php.d/igbinary.ini,
    /etc/centminmod/php.d/imagick.ini,
    /etc/centminmod/php.d/mailparse.ini,
    /etc/centminmod/php.d/memcache.ini,
    /etc/centminmod/php.d/memcached.ini,
    /etc/centminmod/php.d/redis.ini,
    /etc/centminmod/php.d/zendopcache.ini

    If i want to override opcache.revalidate_freq 180 seconds default, I'd create a .ini file after /etc/centminmod/php.d/zendopcache.ini alphabetically i.e. /etc/centminmod/php.d/zzendopcache.ini

    So ordered after zendopcache.ini
    Code (Text):
    php --ini
    Configuration File (php.ini) Path: /usr/local/lib
    Loaded Configuration File:         /usr/local/lib/php.ini
    Scan for additional .ini files in: /etc/centminmod/php.d
    Additional .ini files parsed:      /etc/centminmod/php.d/a_customphp.ini,
    /etc/centminmod/php.d/curlcainfo.ini,
    /etc/centminmod/php.d/geoip.ini,
    /etc/centminmod/php.d/igbinary.ini,
    /etc/centminmod/php.d/imagick.ini,
    /etc/centminmod/php.d/mailparse.ini,
    /etc/centminmod/php.d/memcache.ini,
    /etc/centminmod/php.d/memcached.ini,
    /etc/centminmod/php.d/redis.ini,
    /etc/centminmod/php.d/zendopcache.ini,
    /etc/centminmod/php.d/zzendopcache.ini


    In /etc/centminmod/php.d/zzendopcache.ini add value say 10 seconds
    Code (Text):
    opcache.revalidate_freq = 10


    Note though reducing revalidation frequency lowers performance of caching all the time 24/7. Best way is just to restart php-fpm and nginx after file updates which are done manually via command shortcut
    Code (Text):
    nprestart

    After restart recheck value is now at 10 seconds
    Code (Text):
    php --ri 'Zend OPcache'
    
    Zend OPcache
    
    Opcode Caching => Disabled
    Optimization => Disabled
    SHM Cache => Enabled
    File Cache => Disabled
    Startup Failed => Opcode Caching is disabled for CLI
    
    Directive => Local Value => Master Value
    opcache.enable => On => On
    opcache.use_cwd => On => On
    opcache.validate_timestamps => On => On
    opcache.inherited_hack => On => On
    opcache.dups_fix => Off => Off
    opcache.revalidate_path => Off => Off
    opcache.log_verbosity_level => 1 => 1
    opcache.memory_consumption => 64 => 64
    opcache.interned_strings_buffer => 8 => 8
    opcache.max_accelerated_files => 8000 => 8000
    opcache.max_wasted_percentage => 5 => 5
    opcache.consistency_checks => 0 => 0
    opcache.force_restart_timeout => 180 => 180
    opcache.revalidate_freq => 10 => 10
    opcache.file_update_protection => 2 => 2
    opcache.preferred_memory_model => no value => no value
    opcache.blacklist_filename => no value => no value
    opcache.max_file_size => 0 => 0
    opcache.protect_memory => 0 => 0
    opcache.save_comments => 1 => 1
    opcache.fast_shutdown => 1 => 1
    opcache.optimization_level => 0x7FFFBFFF => 0x7FFFBFFF
    opcache.enable_file_override => On => On
    opcache.enable_cli => Off => Off
    opcache.error_log => no value => no value
    opcache.restrict_api => no value => no value
    opcache.lockfile_path => /tmp => /tmp
    opcache.file_cache => no value => no value
    opcache.file_cache_only => 0 => 0
    opcache.file_cache_consistency_checks => 1 => 1
    opcache.huge_code_pages => Off => Off

    Any php related setting can override and customised this way as well :)
     
    • Like Like x 1
    • Winner Winner x 1
  4. Jay Chen

    Jay Chen Member

    54
    11
    8
    Sep 10, 2017
    Ratings:
    +21
    Local Time:
    1:28 AM
    I make frequent changes to wordpress template, I guess I will have to restart it every time, because I don't want to lose any caching performance. Thanks eva2000, always so responsive and give detailed explanation to the solutions.
     
    • Like Like x 1
  5. Jay Chen

    Jay Chen Member

    54
    11
    8
    Sep 10, 2017
    Ratings:
    +21
    Local Time:
    1:28 AM
    Another problem I encountered is that website is showing different contents if I visit the site via wifi or via cellular data.

    This is weird as hell, I will restart php and nginx to see if this fix this issue.
     
  6. Jay Chen

    Jay Chen Member

    54
    11
    8
    Sep 10, 2017
    Ratings:
    +21
    Local Time:
    1:28 AM
    nprestart seems to fix all the problem, I will keep an close eye to see if this happens again. Thanks.
     
    • Informative Informative x 1
  7. eva2000

    eva2000 Administrator Staff Member

    36,333
    7,979
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,287
    Local Time:
    3:28 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    Good to hear :)
     
    • Like Like x 1
  8. Jay Chen

    Jay Chen Member

    54
    11
    8
    Sep 10, 2017
    Ratings:
    +21
    Local Time:
    1:28 AM
    I checked this morning, I am still having issue where different content is being shown on mobile devices that are connected to wifi and those that are using mobile data.

    Those connected with wifi seems to be getting the right content, those using mobile data are getting older content.

    I will go do some digging and let you guys know if I managed to find the problem. In the mean time, any of you encountered this before?
     
  9. Jay Chen

    Jay Chen Member

    54
    11
    8
    Sep 10, 2017
    Ratings:
    +21
    Local Time:
    1:28 AM
    I did some digging and find out that older caches is not being invalidated, or somehow they are still being served.

    See the screen shot below, I have a post published at 7am, then at 8am and 12pm.
    Everytime a new post is published, cache enabler should clear the cache of home page, but when I look at the source of home page, the 7am cached version of home page is being served.

    I have not been able to locate the cause of the problem, will keep you posted with my findings and progress.
    published-posts.PNG



    cache-served.PNG
     
  10. eva2000

    eva2000 Administrator Staff Member

    36,333
    7,979
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,287
    Local Time:
    3:28 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    when you ran centmin.sh menu option 22, did you opt to exclude mobile devices from cache enabler caching ? maybe your ISP provider has some form of transparent proxy cache for mobile data ?
     
  11. Jay Chen

    Jay Chen Member

    54
    11
    8
    Sep 10, 2017
    Ratings:
    +21
    Local Time:
    1:28 AM
    I didn't. My website is a responsive website, it doesn't make sense to exclude model from caching.

    Now I am getting the right cache, looks like something is wrong with cache invalidation process. I will have to keep digging.
     
  12. eva2000

    eva2000 Administrator Staff Member

    36,333
    7,979
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,287
    Local Time:
    3:28 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    If you're mobile responsive, caching will have some issues and usually it's recommended to exclude from caching for cache enabler WordPress Cache Enabler Plugin - KeyCDN Support

    Most Wordpress full page cache plugins will have trouble with mobile responsive caching
     
  13. Jay Chen

    Jay Chen Member

    54
    11
    8
    Sep 10, 2017
    Ratings:
    +21
    Local Time:
    1:28 AM
    I don't think I understand this, responsive theme produce the same html for desktop and mobile, it is up to browsers to display/hide contents based on CSS, shouldn't be a problem. Unless I am missing something here.

    i thought mobile theme or plugin produce different html for desktop and mobile.
     
  14. Jay Chen

    Jay Chen Member

    54
    11
    8
    Sep 10, 2017
    Ratings:
    +21
    Local Time:
    1:28 AM
    I did more digging, it looks like both desktop/chrome and mobile/chrome ios are both showing older cache.

    Referring to the screenshot above, right now it is 3:54pm, the latest post should be Whenever I try to tell the truth, but when i visited the site, latest post being shown is I keep trying to make things idiot proof, which is published at 12pm, right before the actual newest post.

    The timstamp on the cache is <!-- Cache Enabler by KeyCDN @ 19.09.2018 13:17:48 (html) -->
     
  15. eva2000

    eva2000 Administrator Staff Member

    36,333
    7,979
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,287
    Local Time:
    3:28 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
  16. Jay Chen

    Jay Chen Member

    54
    11
    8
    Sep 10, 2017
    Ratings:
    +21
    Local Time:
    1:28 AM
    I want to make sure I can narrow the problem down to Cache Enabler. I disabled the plugin, restart nginx and php, but I am still seeing cached page - <!-- Cache Enabler by KeyCDN @ 19.09.2018 15:52:48 (html) -->.

    Is this caused by some settings on CMM?
     
  17. eva2000

    eva2000 Administrator Staff Member

    36,333
    7,979
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,287
    Local Time:
    3:28 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    what if you restart nginx + php-fpm ?
    Code (Text):
    nprestart
    

    disabling cache enabler plugin doesn't clear the caches which are stored on disk and read by nginx for advanced cache enabler caching bypassing PHP
     
  18. Jay Chen

    Jay Chen Member

    54
    11
    8
    Sep 10, 2017
    Ratings:
    +21
    Local Time:
    1:28 AM
    I tried nprestart, it was still serving cached page. But the site is not serving any cached contents any more, they are all invalidated.

    So I am thinking now is a good time to test other cache plugins and see if I run into the same problem.

    I mainly want to try Hyper Cache, Hyper Cache, I used it before and never have any problem with it. Do I have to change any config files on CMM to use a different cache plugin?

    Thanks.
     
  19. Jay Chen

    Jay Chen Member

    54
    11
    8
    Sep 10, 2017
    Ratings:
    +21
    Local Time:
    1:28 AM
    Wait, if nginx is serving the caches and not cache enabler, how does nginx know when to invalidate the cache.
    Maybe this is the problem?
     
  20. eva2000

    eva2000 Administrator Staff Member

    36,333
    7,979
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,287
    Local Time:
    3:28 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    when cache enabler invalidates it will remove the cache from disk so nginx won't read it and serve non-cached version
     
..