The scenario is the following:
- The request comes on server side.
- The server gets the content of a file and modifies it, computing the information that comes from request.
- The server sends the response sending the computed information (string) using
response.end(content)
.
Is it possible to cache such response in browser?
Right now, I only cache in browser files (images, CSS & HTML files etc) that are streamed using stream.pipe(response)
. I use stats = Fs.lstatSync(fileName)
to get stats about the file. Caching stuff code is located here.
If the response is just text, I cannot have any stats, because I don't have a file but a long string.
How can I cache text responses? How can I handle them modifications?