Raja
Raja

Reputation: 3627

Which one is faster php File based caching or Opcache

I just recently got an updated about Opcache in php and i am little familiar with file based caching in Codeigniter.

But i thought as of now File based caching is faster other caching techniques, since there won't be any database access and it directly connect to the generated html file to load. So it should be fast than other techniques.

So i have searched in Google and some websites compared the speed of caching by benchmarking it where they mentioned File caching is slow on retrieve when compared to other caching technique memcache and Opcache php and I am confused with the report.

I know every caching technique having their own pros and cons. Suggest me on the situation so my page won't be need of real time data and currently i am using file based caching. So Is it ok to go Opcache or Memache?

Upvotes: 2

Views: 2156

Answers (2)

Dat Tran
Dat Tran

Reputation: 1586

OPcache improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request.
File based caching that you are talking about is about caching your variable to a file and get it on later. (often use when the time for getting data is very slow)
Therefore, you can still use file based caching to store your variable and use Opcache for caching your script. However, to cache your data to memory will be much more faster. In that case, try Memcached/Redis or anything you can find.

Upvotes: 0

user399666
user399666

Reputation: 19909

Opcache and Memcached store data in memory. In the vast majority of cases, retrieving data from memory is faster than retrieving data from the file system. The drawback? Running Memcached and using an opcache will obviously use up some of your server's memory.

Upvotes: 3

Related Questions