Revealed :👨‍💼 What does websites like Facebook and YouTube process in the background ? | StudyObject

We are going to reveal the secrets behind websites like Facebook and YouTube background work ! Interesting Keep it reading!

I always knew that heavy loaded sites like Facebook and YouTube does some kind of optimisation to make it as fast as possible for users. They use load balancing, content distribution network etc., we are not going to discuss these, you already know it !

Today our focus is Object Caching in deep !

Object caching can make your website supercharged! Let’s dive in into the real cool tech stuff. We will discuss how exactly you can work with object caching with persistent connections. Please note that by default object caching is not persistent in WordPress.

Some people can argue on selecting Object caching over Database caching. We will elaborate on the same and finally conclude on which is better and which one to use in your environment.

WordPress maintains an internal object cache which automatically stores any data from the database in PHP memory to prevent unnecessary queries.

Golden Rule 1 :

It is noteworthy that WordPress maintains object cache only for complex queries and not for all database queries during that single connection request. However WordPress will discard all of those objects at the end of the request.

Golden Rule 2 :

WordPress Object caching is not persistent. So it requires the objects to be rebuilt from scratch for the next page load.

Which one to use Object Caching or Database Caching

Database cache caches the results of common database queries to enhance performance and Object Cache caches the results of complex database queries to reduce server load.

So if you are looking to boost performance , you should use database caching as it will keep common queries loaded into cache. Let’s say most of your website visitors are content consumers. So it becomes preferable to use database caching.

Let’s say your visitors performs critical operations like buying or selling , then you should prefer Object Caching. With Object caching, a lot of the backend complex queries will be object cached . Hence it will save you from overloading the CPU. With Object Caching PHP execution time is improved while lessening the load on the database. It is particularly helpful in situations where much of the page is difficult to cache from the front-end, like for e-commerce applications.

For more queries you may refer here.

Achieving persistent Object Caching

There are many ways to achieve persistent caching. The most preferred way is to use Memcached. If you want to know how memached can be installed on your server, give it a read at plex.

Please note you must have memcached daemon running on linux and  PECL memcached extension installed in PHP.

Memcached daemon listens by default on tcp 11211 port

You can check using following commands to see if memcached daemon and PHP extension for memcached is supported !

ps -ef | grep memcached


ps -eaf | grep memcachedmemcach+ 19649 1 0 Jun23 ? 00:02:18 /usr/bin/memcached -u memcached -p 11211 -m 64 -c 1024 -l,::1

netstat -tulpn | grep :11211


tcp 0 0* LISTEN 19649/memcached
tcp6 0 0 ::1:11211 :::* LISTEN 19649/memcached


Also check if PHP contains the PECL memcahced extension

php -i | grep “memcached support”


memcached support => enabled

Gold as it looks to be:


Using Object Caching and Database Caching together may lead to higher utilisation of server resources. So it becomes vital to select either of them based on your requirement. It is always recommended to use Object Caching without DB caching or vice versa.


Which one of these you prefer? Share your thoughts!


Author: Rajnish K

About Author :

Rajnishk is R&D Expert ,passionate for Web Stack & an Entrepreneur . He can be reached at [email protected]


Subscribe To Our Newsletter ! Enter your email address:

Delivered by FeedBurner


StudyObject © 2020. All rights reserved.