{"id":796,"date":"2022-12-01T13:58:58","date_gmt":"2022-12-01T19:58:58","guid":{"rendered":"https:\/\/developers.wpengine.com\/blog\/?p=796"},"modified":"2023-05-11T11:11:48","modified_gmt":"2023-05-11T17:11:48","slug":"catching-cache-using-apollo-client-next-js-atlas","status":"publish","type":"post","link":"https:\/\/wpengine.com\/builders\/catching-cache-using-apollo-client-next-js-atlas\/","title":{"rendered":"Catching The Cache using the Apollo Client and Next.js on Atlas"},"content":{"rendered":"\n<p>In this article, I will discuss a common issue and best practices when using the Apollo client with Atlas, WP Engine\u2019s headless WordPress hosting platform.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>The Apollo Client<\/strong> \ud83e\uddd1\u200d\ud83d\ude80<\/h2>\n\n\n\n<p>The Apollo client is a popular comprehensive state management library for JavaScript that enables you to manage both local and remote data with <a href=\"https:\/\/graphql.org\/\">GraphQL<\/a>.&nbsp; It has features you can use for fetching, modifying application data, and caching.&nbsp; This article\u2019s focus is the caching mechanism in Apollo.<\/p>\n\n\n\n<p>If you need foundational knowledge of Apollo, please visit their <a href=\"https:\/\/www.apollographql.com\/docs\/\">docs<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Usage with Next.js and&nbsp; Headless WordPress<\/strong><\/h3>\n\n\n\n<p><a href=\"https:\/\/nextjs.org\/\">Next.js<\/a> is the most popular open-source front-end Javascript framework.&nbsp; Most developers that have adopted a Headless WordPress architecture choose Next.js because it allows you to choose and pick how to render and fetch your data from WordPress.&nbsp; You can use Static Site Generation, Server Side Rendering, or Incremental Static Regeneration.&nbsp;<\/p>\n\n\n\n<p>Out of the box, Next.js uses its <code>getStaticProps<\/code> function which is the method for statically generating your site at build time.&nbsp; You can also choose <code>getServerSideProps<\/code> which is the opposite of static generation.&nbsp; This tells the Next.js component to populate the props and render them into a static HTML page at run time.<\/p>\n\n\n\n<p>Within these methods, it is common to use the <a href=\"https:\/\/www.wpgraphql.com\/\">WPGraphQL<\/a> API and GraphQL with Apollo to fetch the page data from WordPress.&nbsp;<\/p>\n\n\n\n<p>Here is the common configuration from the Apollo docs below:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-code-table shcb-line-numbers\"><span class='shcb-loc'><span><span class=\"hljs-keyword\">import<\/span> { InMemoryCache, ApolloClient } <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">'@apollo\/client'<\/span>;\n<\/span><\/span><span class='shcb-loc'><span>\n<\/span><\/span><span class='shcb-loc'><span><span class=\"hljs-keyword\">const<\/span> client = <span class=\"hljs-keyword\">new<\/span> ApolloClient({\n<\/span><\/span><span class='shcb-loc'><span>   <span class=\"hljs-comment\">\/\/..other arguements...<\/span>\n<\/span><\/span><span class='shcb-loc'><span><span class=\"hljs-attr\">cache<\/span>: <span class=\"hljs-keyword\">new<\/span> InMemoryCache(options)\n<\/span><\/span><span class='shcb-loc'><span>})\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>What you would expect when using <code>getStaticProps<\/code> is for the WordPress data to be fresh and updated upon every rebuild of the page and site.&nbsp; <\/p>\n\n\n\n<p>On the flip side of that,&nbsp; When you use <code>getServerSideProps<\/code> and fetch the WordPress data at runtime, you should see the fresh data immediately because the server is doing the work upon every user\u2019s request.<\/p>\n\n\n\n<p>One issue we have seen developers run into is seeing stale WordPress data show up in their front-end application, something that can happen with Apollo\u2019s default caching policy. &nbsp; And this is not ideal when you have mission-critical sites that rely on up-to-date data as close to real-time as possible.<\/p>\n\n\n\n<p>This is where the Apollo client configuration comes into play.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Catching the Apollo Cache<\/strong> \ud83d\udcb8<\/h2>\n\n\n\n<p>The Apollo client has its own caching mechanism and this is where the issue lies.&nbsp; Most people using Apollo might be unaware that when creating an Apollo custom configuration in their project, it has its own caching layer that can affect your data freshness, in relation to what hosting platform you are using. In this article\u2019s case, we are talking about the Atlas platform.<\/p>\n\n\n\n<p>Now, some serverless platforms will naturally run the Apollo cache to be shorter-lived.&nbsp; In Atlas, it runs a full node server and the outcome of this is a longer-lived Apollo cache.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Configuration with Atlas<\/strong><\/h3>\n\n\n\n<p>Our very own solutions architect <a href=\"https:\/\/github.com\/jordanmaslyn\">Jordan Maslyn<\/a> created this code snippet for Atlas users to alleviate the issue when using Apollo:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-code-table shcb-line-numbers\"><span class='shcb-loc'><span><span class=\"hljs-keyword\">import<\/span> {\n<\/span><\/span><span class='shcb-loc'><span>  ApolloClient,\n<\/span><\/span><span class='shcb-loc'><span>  InMemoryCache,\n<\/span><\/span><span class='shcb-loc'><span>  HttpLink,\n<\/span><\/span><span class='shcb-loc'><span>  ApolloLink,\n<\/span><\/span><span class='shcb-loc'><span>} <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">\"@apollo\/client\"<\/span>;\n<\/span><\/span><span class='shcb-loc'><span>\n<\/span><\/span><span class='shcb-loc'><span><span class=\"hljs-keyword\">const<\/span> link = ApolloLink.from(&#91;\n<\/span><\/span><span class='shcb-loc'><span>  <span class=\"hljs-keyword\">new<\/span> HttpLink({\n<\/span><\/span><span class='shcb-loc'><span>    <span class=\"hljs-attr\">uri<\/span>: <span class=\"hljs-string\">`<span class=\"hljs-subst\">${process.env.NEXT_PUBLIC_WORDPRESS_API_URL}<\/span>\/graphql`<\/span>,\n<\/span><\/span><span class='shcb-loc'><span>    <span class=\"hljs-attr\">useGETForQueries<\/span>:\n<\/span><\/span><span class='shcb-loc'><span>      process.env.CACHE_GRAPHQL_RESPONSES !== <span class=\"hljs-string\">\"false\"<\/span> ? <span class=\"hljs-literal\">true<\/span> : <span class=\"hljs-literal\">false<\/span>,\n<\/span><\/span><span class='shcb-loc'><span>  }),\n<\/span><\/span><span class='shcb-loc'><span>]);\n<\/span><\/span><span class='shcb-loc'><span>\n<\/span><\/span><span class='shcb-loc'><span><span class=\"hljs-keyword\">export<\/span> <span class=\"hljs-keyword\">const<\/span> client = <span class=\"hljs-keyword\">new<\/span> ApolloClient({\n<\/span><\/span><span class='shcb-loc'><span>  link,\n<\/span><\/span><span class='shcb-loc'><span>  <span class=\"hljs-attr\">cache<\/span>: <span class=\"hljs-keyword\">new<\/span> InMemoryCache(),\n<\/span><\/span><span class='shcb-loc'><span>  <span class=\"hljs-attr\">defaultOptions<\/span>: {\n<\/span><\/span><span class='shcb-loc'><span>    <span class=\"hljs-attr\">query<\/span>: {\n<\/span><\/span><span class='shcb-loc'><span>      <span class=\"hljs-attr\">fetchPolicy<\/span>:\n<\/span><\/span><span class='shcb-loc'><span>        process.env.CACHE_GRAPHQL_RESPONSES !== <span class=\"hljs-string\">\"false\"<\/span>\n<\/span><\/span><span class='shcb-loc'><span>          ? <span class=\"hljs-string\">\"cache-first\"<\/span>\n<\/span><\/span><span class='shcb-loc'><span>          : <span class=\"hljs-string\">\"network-only\"<\/span>,\n<\/span><\/span><span class='shcb-loc'><span>    },\n<\/span><\/span><span class='shcb-loc'><span>  },\n<\/span><\/span><span class='shcb-loc'><span>});\n<\/span><\/span><span class='shcb-loc'><span>\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Let\u2019s break down what is happening in Jordan\u2019s code snippet.<\/p>\n\n\n\n<p>The Apollo client uses <code>HttpLink<\/code> to send GraphQL operations to a server over HTTP.&nbsp;&nbsp;<\/p>\n\n\n\n<p>The link supports both <code>POST<\/code> and <code>GET<\/code> requests, and it can modify HTTP options on a per-query basis.<\/p>\n\n\n\n<p>The code block above starts with an Apollo Link that equals the new link variable and uses <code>HttpLink<\/code>.&nbsp; The <code>useGETForQueries<\/code> key is a constructor option that <code>Httplink<\/code> accepts. <\/p>\n\n\n\n<p>If set to true, <code>HttpLink<\/code> uses <code>GET<\/code> requests instead of <code>POST<\/code> requests to execute query operations (but not mutation operations). <code>GET<\/code> requests can allow us to leverage some default caching from the protocol (and helps improve the performance and scalability of your WordPress server!), but if we are interested in prioritizing data freshness over performance\/scalability, we will want to disable that feature.<\/p>\n\n\n\n<p>The next thing to focus on is the <code>fetchPolicy <\/code>key. This key defines how Apollo Client uses the cache for a particular query. The default policy is cache-first, which means Apollo Client checks the cache to see if the result is present before making a network request.<\/p>\n\n\n\n<p><br>If the result is present, no network request occurs.&nbsp; Within the const variable that is exported as the new Apollo Client, we have an environment variable called CACHE_GRAPHQL_RESPONSES which is set to \u201cfalse\u201d.&nbsp; <\/p>\n\n\n\n<p>This means that wherever an Atlas customer instantiates their Apollo client, it will <a href=\"https:\/\/www.apollographql.com\/docs\/react\/caching\/advanced-topics#bypassing-the-cache\">bypass<\/a> the Apollo Cache.&nbsp; By using the \u201cnetwork-only\u201d <code>fetchPolicy<\/code>, we can deter Apollo from caching responses which prioritizes data freshness (and allows other layers with more awareness of your content to handle the caching as discussed in the next section).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>The Trade-Off<\/strong><\/h2>\n\n\n\n<p>Like everything in web development, there are tradeoffs in any approach you decide to take.&nbsp; Bypassing the Apollo cache will give you the up-to-date, fresh data that you require.&nbsp; However, the trade-off here is that you are not serving cached files which are served quicker by default.<\/p>\n\n\n\n<p>Because you will be running the request on the server, the performance for page load is decreased and you will increase the load on your server. However, there is a new tool that can let you have both!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Optional Solution<\/strong>: \u26a1WPGraphQL  Smart Cache \u26a1<\/h3>\n\n\n\n<p>An option to consider is <a href=\"https:\/\/github.com\/wp-graphql\/wp-graphql-smart-cache\">WPGraphQL Smart Cache<\/a>.&nbsp; This plugin captures the results of GraphQL Requests, stores the response in a cache, and uses the cached response for future requests instead of executing the query and all of its resolvers at each request.&nbsp; <\/p>\n\n\n\n<p>This means you are not evening hitting your WordPress server, in turn decreasing the load and increasing your performance. Above and beyond Apollo\u2019s caching implementation, WPGraphQL Smart Cache knows when you update your content and can purge any related cached responses accordingly. <\/p>\n\n\n\n<p>This lets you continue having the performance and scalability benefits of an API caching layer while also delivering the freshest version of your data as it is requested by your front-end application.<\/p>\n\n\n\n<p>I go into detail about it in my <a href=\"https:\/\/wpengine.com\/builders\/wpgraphql-smart-cache-with-next-js-and-apollo\">blog post<\/a>!&nbsp; Please consider this as an option, as this will provide an optional solution for the long-running Apollo Cache on Atlas.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion \ud83d\ude80<\/h2>\n\n\n\n<p>The powerful combination of Next.js, the Apollo Client, and WPGraphQL can give your developers an amazing developer experience as well as give your users an amazing experience when requesting information from your apps and sites built on these tools.<\/p>\n\n\n\n<p>When using WP Engine\u2019s Atlas, we want to ensure that the tools you use on our platform are fully optimized within the use case of your site especially when it comes to the caching layer, a crucial component of any web development architecture.<\/p>\n\n\n\n<p>Hopefully, if you are an Atlas customer or considering using Atlas and are choosing Next.js and Apollo, you find this helpful.&nbsp; Special thanks to Jordan Maslyn!&nbsp; As always, let us know your thoughts, feedback, and suggestions in our <a href=\"https:\/\/discord.com\/invite\/J2khkF9XYK\">discord<\/a>!&nbsp; Stoked! <\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, I will discuss a common issue and best practices when using the Apollo client with Atlas, WP Engine\u2019s headless WordPress hosting platform. The Apollo Client \ud83e\uddd1\u200d\ud83d\ude80 The [&hellip;]<\/p>\n","protected":false},"author":20,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_EventAllDay":false,"_EventTimezone":"","_EventStartDate":"","_EventEndDate":"","_EventStartDateUTC":"","_EventEndDateUTC":"","_EventShowMap":false,"_EventShowMapLink":false,"_EventURL":"","_EventCost":"","_EventCostDescription":"","_EventCurrencySymbol":"","_EventCurrencyCode":"","_EventCurrencyPosition":"","_EventDateTimeSeparator":"","_EventTimeRangeSeparator":"","_EventOrganizerID":[],"_EventVenueID":[],"_OrganizerEmail":"","_OrganizerPhone":"","_OrganizerWebsite":"","_VenueAddress":"","_VenueCity":"","_VenueCountry":"","_VenueProvince":"","_VenueState":"","_VenueZip":"","_VenuePhone":"","_VenueURL":"","_VenueStateProvince":"","_VenueLat":"","_VenueLng":"","_VenueShowMap":false,"_VenueShowMapLink":false,"footnotes":""},"categories":[23],"tags":[],"class_list":["post-796","post","type-post","status-publish","format-standard","hentry","category-headless"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Catching The Cache using the Apollo Client and Next.js on Atlas - Builders<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wpengine.com\/builders\/catching-cache-using-apollo-client-next-js-atlas\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Catching The Cache using the Apollo Client and Next.js on Atlas - Builders\" \/>\n<meta property=\"og:description\" content=\"In this article, I will discuss a common issue and best practices when using the Apollo client with Atlas, WP Engine\u2019s headless WordPress hosting platform. The Apollo Client \ud83e\uddd1\u200d\ud83d\ude80 The [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wpengine.com\/builders\/catching-cache-using-apollo-client-next-js-atlas\/\" \/>\n<meta property=\"og:site_name\" content=\"Builders\" \/>\n<meta property=\"article:published_time\" content=\"2022-12-01T19:58:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-05-11T17:11:48+00:00\" \/>\n<meta name=\"author\" content=\"Francis Agulto\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@wpebuilders\" \/>\n<meta name=\"twitter:site\" content=\"@wpebuilders\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Francis Agulto\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/catching-cache-using-apollo-client-next-js-atlas\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/catching-cache-using-apollo-client-next-js-atlas\\\/\"},\"author\":{\"name\":\"Francis Agulto\",\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#\\\/schema\\\/person\\\/bcdcb4ac0b215c34b6b30e440a24dc54\"},\"headline\":\"Catching The Cache using the Apollo Client and Next.js on Atlas\",\"datePublished\":\"2022-12-01T19:58:58+00:00\",\"dateModified\":\"2023-05-11T17:11:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/catching-cache-using-apollo-client-next-js-atlas\\\/\"},\"wordCount\":1138,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#organization\"},\"articleSection\":[\"Headless\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/wpengine.com\\\/builders\\\/catching-cache-using-apollo-client-next-js-atlas\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/catching-cache-using-apollo-client-next-js-atlas\\\/\",\"url\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/catching-cache-using-apollo-client-next-js-atlas\\\/\",\"name\":\"Catching The Cache using the Apollo Client and Next.js on Atlas - Builders\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#website\"},\"datePublished\":\"2022-12-01T19:58:58+00:00\",\"dateModified\":\"2023-05-11T17:11:48+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/catching-cache-using-apollo-client-next-js-atlas\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/wpengine.com\\\/builders\\\/catching-cache-using-apollo-client-next-js-atlas\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/catching-cache-using-apollo-client-next-js-atlas\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Catching The Cache using the Apollo Client and Next.js on Atlas\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#website\",\"url\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/\",\"name\":\"Builders\",\"description\":\"Reimagining the way we build with WordPress.\",\"publisher\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#organization\",\"name\":\"WP Engine\",\"url\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/wp-content\\\/uploads\\\/2024\\\/05\\\/WP-Engine-Horizontal@2x.png\",\"contentUrl\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/wp-content\\\/uploads\\\/2024\\\/05\\\/WP-Engine-Horizontal@2x.png\",\"width\":348,\"height\":68,\"caption\":\"WP Engine\"},\"image\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/wpebuilders\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCh1WuL54XFb9ZI6m6goFv1g\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#\\\/schema\\\/person\\\/bcdcb4ac0b215c34b6b30e440a24dc54\",\"name\":\"Francis Agulto\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0c8a05c76944fc987d57296c96dc368055844527088c0aa44297edbfa8b82546?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0c8a05c76944fc987d57296c96dc368055844527088c0aa44297edbfa8b82546?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0c8a05c76944fc987d57296c96dc368055844527088c0aa44297edbfa8b82546?s=96&d=mm&r=g\",\"caption\":\"Francis Agulto\"},\"description\":\"Fran Agulto is a Developer Advocate at WP Engine. He is a lover of all things headless WordPress, Rock Climbing, and overall being stoked for people that love what they do and share that stoke with others! Follow me on Twitter for cool stoked headless WP!\",\"url\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/author\\\/francis-agultowpengine-com-2-2-2-2-2-2-2-2-2-2-2-2\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Catching The Cache using the Apollo Client and Next.js on Atlas - Builders","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wpengine.com\/builders\/catching-cache-using-apollo-client-next-js-atlas\/","og_locale":"en_US","og_type":"article","og_title":"Catching The Cache using the Apollo Client and Next.js on Atlas - Builders","og_description":"In this article, I will discuss a common issue and best practices when using the Apollo client with Atlas, WP Engine\u2019s headless WordPress hosting platform. The Apollo Client \ud83e\uddd1\u200d\ud83d\ude80 The [&hellip;]","og_url":"https:\/\/wpengine.com\/builders\/catching-cache-using-apollo-client-next-js-atlas\/","og_site_name":"Builders","article_published_time":"2022-12-01T19:58:58+00:00","article_modified_time":"2023-05-11T17:11:48+00:00","author":"Francis Agulto","twitter_card":"summary_large_image","twitter_creator":"@wpebuilders","twitter_site":"@wpebuilders","twitter_misc":{"Written by":"Francis Agulto","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/wpengine.com\/builders\/catching-cache-using-apollo-client-next-js-atlas\/#article","isPartOf":{"@id":"https:\/\/wpengine.com\/builders\/catching-cache-using-apollo-client-next-js-atlas\/"},"author":{"name":"Francis Agulto","@id":"https:\/\/wpengine.com\/builders\/#\/schema\/person\/bcdcb4ac0b215c34b6b30e440a24dc54"},"headline":"Catching The Cache using the Apollo Client and Next.js on Atlas","datePublished":"2022-12-01T19:58:58+00:00","dateModified":"2023-05-11T17:11:48+00:00","mainEntityOfPage":{"@id":"https:\/\/wpengine.com\/builders\/catching-cache-using-apollo-client-next-js-atlas\/"},"wordCount":1138,"commentCount":0,"publisher":{"@id":"https:\/\/wpengine.com\/builders\/#organization"},"articleSection":["Headless"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/wpengine.com\/builders\/catching-cache-using-apollo-client-next-js-atlas\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/wpengine.com\/builders\/catching-cache-using-apollo-client-next-js-atlas\/","url":"https:\/\/wpengine.com\/builders\/catching-cache-using-apollo-client-next-js-atlas\/","name":"Catching The Cache using the Apollo Client and Next.js on Atlas - Builders","isPartOf":{"@id":"https:\/\/wpengine.com\/builders\/#website"},"datePublished":"2022-12-01T19:58:58+00:00","dateModified":"2023-05-11T17:11:48+00:00","breadcrumb":{"@id":"https:\/\/wpengine.com\/builders\/catching-cache-using-apollo-client-next-js-atlas\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wpengine.com\/builders\/catching-cache-using-apollo-client-next-js-atlas\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/wpengine.com\/builders\/catching-cache-using-apollo-client-next-js-atlas\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/wpengine.com\/builders\/"},{"@type":"ListItem","position":2,"name":"Catching The Cache using the Apollo Client and Next.js on Atlas"}]},{"@type":"WebSite","@id":"https:\/\/wpengine.com\/builders\/#website","url":"https:\/\/wpengine.com\/builders\/","name":"Builders","description":"Reimagining the way we build with WordPress.","publisher":{"@id":"https:\/\/wpengine.com\/builders\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wpengine.com\/builders\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/wpengine.com\/builders\/#organization","name":"WP Engine","url":"https:\/\/wpengine.com\/builders\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wpengine.com\/builders\/#\/schema\/logo\/image\/","url":"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/2024\/05\/WP-Engine-Horizontal@2x.png","contentUrl":"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/2024\/05\/WP-Engine-Horizontal@2x.png","width":348,"height":68,"caption":"WP Engine"},"image":{"@id":"https:\/\/wpengine.com\/builders\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/wpebuilders","https:\/\/www.youtube.com\/channel\/UCh1WuL54XFb9ZI6m6goFv1g"]},{"@type":"Person","@id":"https:\/\/wpengine.com\/builders\/#\/schema\/person\/bcdcb4ac0b215c34b6b30e440a24dc54","name":"Francis Agulto","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/0c8a05c76944fc987d57296c96dc368055844527088c0aa44297edbfa8b82546?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/0c8a05c76944fc987d57296c96dc368055844527088c0aa44297edbfa8b82546?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0c8a05c76944fc987d57296c96dc368055844527088c0aa44297edbfa8b82546?s=96&d=mm&r=g","caption":"Francis Agulto"},"description":"Fran Agulto is a Developer Advocate at WP Engine. He is a lover of all things headless WordPress, Rock Climbing, and overall being stoked for people that love what they do and share that stoke with others! Follow me on Twitter for cool stoked headless WP!","url":"https:\/\/wpengine.com\/builders\/author\/francis-agultowpengine-com-2-2-2-2-2-2-2-2-2-2-2-2\/"}]}},"_links":{"self":[{"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/posts\/796","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/comments?post=796"}],"version-history":[{"count":0,"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/posts\/796\/revisions"}],"wp:attachment":[{"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/media?parent=796"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/categories?post=796"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/tags?post=796"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}