Is it possible in an application, that only few actions will work with opcache.
I don’t want to save all data save in cache. I want to save only few data as per requirement.
That is no good idea and I have serious doubts that’ll be possible at all. Those actions will likely pull in framework code into the opcache. You can try to explicitly blacklist a set of files.
As for your original problem: perhaps your Apache config doesn’t allow a [font=“Courier New”].htaccess[/font] were you first placed it. Check which [font=“Courier New”]AllowOverride[/font] directives match that directory.
rka05
(Raghav Agarwal 05)
June 17, 2014, 12:59pm
14
That is no good idea and I have serious doubts that’ll be possible at all. Those actions will likely pull in framework code into the opcache. You can try to explicitly blacklist a set of files.
As for your original problem: perhaps your Apache config doesn’t allow a [font=“Courier New”].htaccess[/font] were you first placed it. Check which [font=“Courier New”]AllowOverride[/font] directives match that directory.
Thanks for the reply.
Yeah you are right I had to change, in httpd.conf AllowOverride directive to All.
And regarding the blacklist option, I also go through this file details. But this doesn’t solve my problem.
Because I can write the path of scripts which are outside of my application.
So this is something which will not work in my case.
Any idea how can I achieve this.
It would be interesting to know why you would want this in the first place.
rka05
(Raghav Agarwal 05)
June 17, 2014, 1:27pm
16
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?
rka05
(Raghav Agarwal 05)
June 18, 2014, 4:20am
18
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.
rka05
(Raghav Agarwal 05)
June 18, 2014, 6:22am
19
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.
rka05
(Raghav Agarwal 05)
June 18, 2014, 7:37am
21
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.
rka05
(Raghav Agarwal 05)
July 17, 2014, 9:20am
23
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.
rka05
(Raghav Agarwal 05)
July 17, 2014, 11:20am
25
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]?
rka05
(Raghav Agarwal 05)
July 17, 2014, 12:01pm
27
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 …
rka05
(Raghav Agarwal 05)
July 17, 2014, 12:24pm
29
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.
rka05
(Raghav Agarwal 05)
July 17, 2014, 12:56pm
31
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 .