Reputation: 509
We got a server with Magento 1.4.2 CE, APC 3.1.9 is installed and Magento is configured to use it as backend cache.
We experienced a weird behaviour with caching. Every change we make in the backend is not displayed until apache2 was restarted/APC opcode cache has been cleared. This includes e.g. changing the Welcome Message or activating/deactivating Google Analytics.
The question: Why does APC cache full pages? We do not want this behaviour and it seems not to be standard. For every little change in the backend, we need to clear the opcode cache. Clearing the Magento Cache does not help.
For completeness, here is our /etc/php5/conf.d/apc.ini
:
extension=/usr/lib/php5/20090626/apc.so
apc.enabled=1
apc.file_update_protection=2
apc.optimization=0
apc.shm_size=128M
apc.include_once_override=0
apc.shm_segments=1
apc.gc_ttl=7200
apc.ttl=7200
apc.num_files_hint=1024
apc.enable_cli=0
Enabling/Disabling Google Analytics will also have no effect after the 7200s TTL. Maybe because our cache doesn't run full at this time. 40% of its capacity is used with about 98% hit rate.
This is the full settings output from apc.php:
apc.cache_by_default 1
apc.canonicalize 1
apc.coredump_unmap 0
apc.enable_cli 0
apc.enabled 1
apc.file_md5 0
apc.file_update_protection 2
apc.filters
apc.gc_ttl 7200
apc.include_once_override 0
apc.lazy_classes 0
apc.lazy_functions 0
apc.max_file_size 1M
apc.mmap_file_mask
apc.num_files_hint 1024
apc.preload_path
apc.report_autofilter 0
apc.rfc1867 0
apc.rfc1867_freq 0
apc.rfc1867_name APC_UPLOAD_PROGRESS
apc.rfc1867_prefix upload_
apc.rfc1867_ttl 3600
apc.serializer default
apc.shm_segments 1
apc.shm_size 128M
apc.slam_defense 1
apc.stat 1
apc.stat_ctime 0
apc.ttl 7200
apc.use_request_time 1
apc.user_entries_hint 4096
apc.user_ttl 0
apc.write_lock 1
Upvotes: 1
Views: 2271
Reputation: 1
You can also Set apc.stat to zero. (apc.stat=0) in your PHP.ini file.
If it is set to 1 it does not look for file updates, which gives better performance but requires an apache restart after an update. Setting to 0 it will check for file updates and add them to the cache (ie. your updates will be visible on the site).
Upvotes: 0
Reputation: 5491
APC keeps both a terminal and web based cache. Since you can only clear the "web" cached hits from a web based URL call and not the command line, This is why after restarting apache clears the APC Web based cache. You'll most likely want to setup a script to clear the cache with a script similar so you can simply call it from the CLI or script.
echo "Clearing APC web cache\n";
system('wget --spider --quiet http://localhost/clear_apc_cache.php');
echo "Clearing APC command line user cache\n";
apc_clear_cache('user');
echo "Clearing APC command line opcode cache\n";
apc_clear_cache();
Obviously you'll need to create the clear_apc_cache.php
corresponding file with the same two APC internal method calls within it, apc_clear_cache();
and apc_clear_cache('user');
Also, I'd setup a local area to view the APC cache as well:
http://www.electrictoolbox.com/apc-php-cache-information/
Upvotes: 1