APC File Cache not working but user cache is fine
Summary: I have PHP(5.3.8) installed as an Apache Module, and installed APC via PECL. The User cache is working fine but the File Cache is not working ( I do have apc.cache_by_default set to 1 so that's not the issue)
Detail: I have just got a VPS (with cPanel/WHM) to test what gains i could get in my application with using apc file cache AND user cache.
So I got the PHP 5.3 compiled in as a DSO (apache module).
Then installed APC via PECL through SSH. (First I tried with WHM Module installer, it also had the same problem, so I tried it via ssh)
All seemed fine and phpinfo showed apc loaded and enabled.
Then I checked with apc.php. All seemed OK
But as I started testing my php application, the stats in apc for File Cache Information state:
Cached Files 0 ( 0.0 Bytes)
Hits 1
Misses 0
Request Rate (hits, misses) 0.00 cache requests/second
Hit Rate 0.00 cache requests/second
Miss Rate 0.00 cache requests/second
Insert Rate 0.00 cache requests/second
Cache full count 0
Which meant no PHP files were being cached, even though I had browsed through over 10 PHP files having multiple includes. So there must have been some Cached 开发者_运维技巧Files.
But the user cache is functioning fine.
User Cache Information
Cached Variables 0 ( 0.0 Bytes)
Hits 1000
Misses 1000
Request Rate (hits, misses) 0.84 cache requests/second
Hit Rate 0.42 cache requests/second
Miss Rate 0.42 cache requests/second
Insert Rate 0.84 cache requests/second
Cache full count 0
The above user cache output is from an APC caching test script which tries to retrieve and store 1000 entries and gives me the times. A sort of simple benchmark.
Can anyone help me here.
Even though apc.cache_by_default = 1, no php files are being cached.This is my apc config
Runtime Settings
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 3600
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 1000
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 32M
apc.slam_defense 1
apc.stat 1
apc.stat_ctime 0
apc.ttl 0
apc.use_request_time 1
apc.user_entries_hint 4096
apc.user_ttl 0
apc.write_lock 1
Also most php files are under 20KB, thus, apc.max_file_size = 1M is not the cause.
I've tried following things with no luck.
- Using 'apc_compile_file ' to force some files into opcode cache with no luck.
- re-installed APC with Debugging enabled, but nothing shows in the error_log
- setting mmap_file_mask to /dev/zero and /tmp/apc.xxxxxx, i have also set /tmp permissions to 777 to no avail
- set apc.enable_cli = 1 AND run a script from cli
- Set apc.max_file_size = 5M (just in case)
- switched php handler from dso to FastCGI in WHM (then switched it back to dso as it did not solve the problem)
- Even tried restarting the container
Any clue anyone.
Note: I had posted the question on serverfault.com but did not get much views or an answer so I'm posting here (as stackoverflow seems to be more active and I have only got 1 month to test my VPS and see if it is of any use over shared)
It seems the problem was with SourceGuardian.
File caching is now working fine after commenting out extension="ixed.5.3.lin" from php.ini.
It was found out by the Support at my hosting provider, so a thumbs up to such great support. I wouldn't have found the issue for days.
Thought should post the answer in case someone else stumbles over this problem.
精彩评论