{"id":2159,"date":"2022-08-13T16:17:01","date_gmt":"2022-08-13T19:17:01","guid":{"rendered":"https:\/\/felipeelia.com.br\/?p=2159"},"modified":"2023-01-16T18:28:32","modified_gmt":"2023-01-16T21:28:32","slug":"wordpress-object-cache-and-redis","status":"publish","type":"post","link":"https:\/\/felipeelia.dev\/wordpress-object-cache-and-redis\/","title":{"rendered":"WordPress, Object Cache, and Redis"},"content":{"rendered":"\n
Do you want to make your WordPress website faster while leveling up your WP programming skills<\/strong>? Object Cache may be your answer!<\/p>\n\n\n\t\t\t\t In the What is an API<\/a> post, I’ve briefly mentioned WordPress Object Cache and how I am using Redis here in the blog. In this post, we will give a better look into both of those things.<\/p>\n\n\n\n Before we start talking about Redis, we need to talk about Object Cache. And before we talk about Object Cache — you saw it coming — we need to talk about cache in general.<\/p>\n\n\n\n Looking for definitions of what is cache on the Internet, common sense seems to be something like this:<\/p>\n\n\n\n Cache is an intermediate storage with quick access<\/strong>, placed between the consumer and the main storage, potentially saving a longer trip.<\/p>\n<\/blockquote>\n\n\n\n Look at the example below. In the first request, we go all the way through the origin server but the server cache saves a copy of the response. In the second request, the copy is served, saving time by not going to the origin server<\/strong>.<\/p>\n\n\n\n With that in mind, we can start thinking about all the several trips needed to visit a website and all the intermediate steps we can insert to save time:<\/p>\n\n\n\n There are lots of other intermediate places we could save a version of the information, these are just some examples. <\/p>\n\n\n\n WordPress Object Cache<\/em> is simple and understand how it works can make the difference during your next job interview \ud83d\ude09<\/p>\n<\/blockquote>\n\n\n\nBefore we go into Object Cache<\/em>… What is cache?<\/h2>\n\n\n\n
\n
Browser cache<\/strong><\/td> Between your browser and the site server, if there is a valid copy of the page on your computer<\/strong>, we save a trip. In fact, we save the entire trip in this case.<\/td><\/tr> CDN<\/strong><\/td> If you are using a CDN like Cloudflare on your website and if there is a valid copy of the content in the CDN<\/strong>, there is no reason to ask for a new copy. It is enough to send just the copy and we save a trip.<\/td><\/tr> WP’s cache<\/strong><\/td> In your WordPress website, if a post was already brought from the database and if the version of the post in memory is still valid<\/strong>, why go to the database again?<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n WordPress Object Cache<\/h2>\n\n\n\n
\n