It would be interesting to know why you would want this in the first place.
It would be interesting to know why you would want this in the first place.
Actually some times. There is an action which simply render a page. And in that page we have static HTML data.
Now if we using opcache, so this data also be cached and if I want to change this static data, to see the change effect I need to reset the cache.
Which I dont want to do. I dont want to cache this static data in my application.
I want to cache only dynamic data, which may sometimes cause error in my application.
So … you’ve got static data that isn’t that static? Is this in production or on your local development system?
This is for my local development system.
And how can I clear cached data? Currently I am doing this with server restart.
I tried function opcache_reset(). But it does not work.
opcache_reset() is working, I wrote it in a different function and then call that function from url.
So it helps me to clear the opcache.
But it clear all cache in the system. How can I clear cache for only specific data, not all data in cache.
You can invalidate specific files via [font=“Courier New”]opcache_invalidate()[/font]. But to be honest: You really shouldn’t enable opcache on your dev system.
Thanks for the suggestion. It will only enable for production not on development environment.
It is working for me. But is there any way by which we can only update changed file from the cache, Not the entire thing.
If I change only one file, then Can I able to get updated data only not update the entire cached data.
I think I am clear.
Hm, I think it’ll be safest for you to just set [font=“Courier New”]opcache.validate_timestamps[/font] back to 1. Be advised that opcache won’t run with optimal performance, as it needs to check every single file for an updated timestamp on each request.
Hi,
Is there any way, I disable opcache in opcache.ini, and enable in my application htacces file.
Well, opcache.enable is marked as [font="Courier New"]PHP_INI_ALL[/font]. So yes, this should be possible.
Hi,
Thanks for your reply.
But I am doing the same. But it doesn’t make any effect.
Any idea!
Thanks
Could you perhaps paste the relevant part of your [font="Courier New"].htaccess[/font]?
Here is my setting in opcache.ini
opcache.enable=0
opcache.validate_timestamps=1
In my htaccess I use
php_flag opcache.enable On
php_flag opcache.validate_timestamps Off
php_value opcache.blacklist_filename "<path to file>"
Here is my settings in ini and htacces file, Is there any problem?
Looks good to me. Can you check if your [font=“Courier New”]AllowOverride[/font] directive is too restrictive? We’ve discussed the same here …
I have set
AllowOverride All
for application directory in my apache configuration.
Oh, wait … can you set [font="Courier New"]validate_timestamps[/font] back to on? If your expiration time is high this could be the culprit.
I changed the [font="Courier New"]validate_timestamps[/font] to On in my htacces file.
But no luck
When I change the above values locally then value for "validate_timestamps" is changed to off, But "opcache.enable" remain off.
Attached file for my local and master opcache settings.
Upon further investigation: It seems opcache must be enabled globally before it can be switched off locally. cf issue #74.
Can we set values of others directives of opcache at runtime.
e.g. I tried to use
php_value opcache.blacklist_filename "<path to the file>""
But it also not work, So it can also not be set at runtime.
And if we can, what settings should I need to do?
I have tested with relative and absolute path for my file, In this file I have write the file folder.
But when I go for phpinfo(), local and global both path are same of blacklist file, default path.
/etc/php.d/blacklistfile
That cannot work since [font="Courier New"]opcache.blacklist_filename[/font] is defined as [font="Courier New"]PHP_INI_SYSTEM[/font], so it can only be set system-wide.