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.

Dynamic Body not to be cached when a Func is used to created the body

See original GitHub issue

I’m using wirenet.net as a standalone process. The response func code below loads an existing file from disk, mutates the string and return it to the user. In my case it mutates all the dates relative to the todays date.

Because it a dynamics response I don’t want the response to be cached. Currently (version 1.5.6), I think, the behaviour is caching the response every time its invoked increasing the memory on each request.

server.Given(Request.Create()
	.WithPath($"/someurl/")
	.UsingPost())
	.RespondWith(Response.Create()
		.WithBody(req =>
		{
			var xml = File.ReadAllText($"./myxmlfile.xml");
		
			xml = MutateString(xml);
			return xml;
		})
	.WithStatusCode(200)
	.WithHeader("Content-Type", "application/xml"));

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:12

github_iconTop GitHub Comments

1reaction
StefHcommented, Oct 17, 2022

A log entry defines the request AND the response.

So the memory will increase, but not as much as before (in case you had big xml-strings to return).

If you do not want log entries at all, you can set the MaxRequestLogCount to 0 in the settings.

1reaction
StefHcommented, Oct 14, 2022

Yes I can understand that the memory is increased because the return value from that Func is a string, and this is saved internally.

However I think that this is only kept in memory for logging the request. So cleaning the logging could help, or I can investigate if in case it’s a Func, the response is not saved to the logging.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Forcing a dynamically loaded javascript to not cache on ...
To this end I have created an external javascript file in which I put the data I want to use. I load the...
Read more >
Server-side caching - Apollo GraphQL Docs
Use @cacheControl for fields that should usually be cached with the same settings. If caching settings might change at runtime, you can use...
Read more >
How to Deal With Caching And Dynamic Content
To make your app cacheable and CDN-ready you have to avoid session-specific content in the cached content rendered on the server. You have...
Read more >
What Is Cache-Control? Everything You Need to Know
Cache -control is an important way by which developers can dictate how resources will be cached when a user browses the internet. Without...
Read more >
Data Fetching, Caching, and Revalidating
Fetching data on the Server with third-party libraries​​ If the segment is dynamic, the output of the request will not be cached and...
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