question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cachable response setting headers

See original GitHub issue

hi, I was able to resolve my previous issue by my own.

Now i am having difficult time in setting headers

Please see my server.js File

const cacheableResponse = require(“cacheable-response”); const express = require(“express”); const next = require(“next”);

const port = parseInt(process.env.PORT, 10) || 5000; const dev = process.env.NODE_ENV !== “production”; const app = next({ dev });

const handle = app.getRequestHandler();

const ssrCache = cacheableResponse({ get: async ({ req, res, path }) => ({ data: await new Promise((resolve) => { let data = app.render(req, res, path, { …req.query, …req.params, }); return data }), ttl: 7200000, // 2 hours }), send: ({ data, res, req }) => res.send(data), });

app.prepare().then(() => { const server = express();

server.get(“/post/:id”, (req, res) => ssrCache({ req, res, path: “/post” }));

server.get(“/”, (req, res) => ssrCache({ req, res, path: ‘/index’ }));

server.get(“*”, (req, res) => handle(req, res));

server.listen(port, (err) => { if (err) throw err; console.log(> Ready on http://localhost:${port}); }); });

But in this headers are not setting which are show in

node_modules\cacheable-response\index.js

Can you please help me, letting me know where i am doing wrong ?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Kikobeatscommented, May 25, 2021

data should be something can be serialized into a non undefined value

1reaction
Kikobeatscommented, May 24, 2021

closing since it’s an issue on our side, but please keep me in touch 🙂

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cache-Control - HTTP - MDN Web Docs
The Cache-Control HTTP header field holds directives (instructions) — in both requests and responses — that control caching in browsers and ...
Read more >
Understanding common cache-related HTTP response headers
This blog post isn't meant to be a comprehensive guide to all layers of web page caching, rather we'll focused on common, cache-related...
Read more >
What is Cache-Control and How HTTP Cache Headers Work
Cache-control is an HTTP header used to specify browser caching policies in both client requests and server responses. Policies include how a resource...
Read more >
Kikobeats/cacheable-response: An HTTP compliant route path ...
The headers associated with the cache copy will the headers from the first request. You need to look at cf-cache-status instead.
Read more >
Setting HTTP Caching Headers - Cache-Control
In the .NET Framework, the Cache-Control header is accessed through the System.Web.HttpCachePolicy class. To set the header to public, private or no- ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found