Skip to content
Discussion options

You must be logged in to vote

With streaming, you no longer have the entire markup before sending the Response to the client.

If you want to use Etag, then it's best to generate that based on your content rather than the resulting HTML.

Something like this:

// routes/blog.$.tsx

// return the Etag headers for full document requests as well
export const headers: HeadersFunction = ({ loaderHeaders }) => loaderHeaders

export async function loader({ request, params }: LoaderFunctionArgs) => {
  let slug = params['*']
  const post = await getPost(slug)
  if (!post) {
    throw new Response('Not Found', { status: 404 })
  }
  const weakHash = generateWeakHash(JSON.stringify(post))
  const etag = request.headers.get('If-Non…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@gonstoll
Comment options

@reloadedhead
Comment options

@gonstoll
Comment options

@reloadedhead
Comment options

Answer selected by gonstoll
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants