Reader small image

You're reading from  Full Stack Web Development with Remix

Product typeBook
Published inNov 2023
Reading LevelIntermediate
PublisherPackt
ISBN-139781801075299
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Andre Landgraf
Andre Landgraf
author image
Andre Landgraf

Andre is a full stack developer from Germany. He graduated with an MS in Information Systems from the Technical University of Munich and was also awarded an MS in Computer Science from Sofia University in Palo Alto. Andre currently lives in Cupertino, California, and he works as a Software Engineer at LinkedIn. Andre loves learning, writing, and speaking about all things web. In his free time, he tutors aspiring developers and builds for the web.
Read more about Andre Landgraf

Right arrow

Working with HTTP caching

The web platform utilizes HTTP headers to control caching behavior. Web clients can read caching directives specified in response headers to reuse previously fetched data. This allows web clients to avoid unnecessary network requests and improve response times. In this section, you will learn about popular HTTP caching headers and strategies and how to use them in Remix. First, we will see how we can define HTTP headers for document responses.

Adding HTTP headers in Remix

Remix’s route module API includes a headers export that we can use to add HTTP headers to the route’s document response. Like the links function, the headers function is only ever executed on the server.

The headers function is called after all loader functions and all parent headers functions. The headers function has access to the parentsHeaders, errorHeaders, actionHeaders, and loaderHeaders objects to update document headers based on the headers added via parent...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Full Stack Web Development with Remix
Published in: Nov 2023Publisher: PacktISBN-13: 9781801075299

Author (1)

author image
Andre Landgraf

Andre is a full stack developer from Germany. He graduated with an MS in Information Systems from the Technical University of Munich and was also awarded an MS in Computer Science from Sofia University in Palo Alto. Andre currently lives in Cupertino, California, and he works as a Software Engineer at LinkedIn. Andre loves learning, writing, and speaking about all things web. In his free time, he tutors aspiring developers and builds for the web.
Read more about Andre Landgraf