I'd like to achieve a deep knowledge about caching mechanism for website assets and even API requests. I read some articles and also searched about it in StackOverflow. There are some examples which show that, if you set for example: max-age: 20; browser will cache the RESTful API response for 20 seconds...
But the important question is that... If browser is able to cache the API response so, why we do have to use some libraries like react-query or using PWA to implement caching scenarios for web applications?
As far as I understand, if we use the browser cache and add max-age browser send request to server but server returns an empty response and makes browser to load from cache... but there is still an issue it would be that request to server to get the empty response.
But if we use something like react-query it even doesn't send that additional request to check cache with server and we can handle caching with zero request and it would a great trick to decrease server requests?
So, I am right? or this scenario is wrong and I couldn't learn it correct?
Thank you
Related
I'm curious if a client(e.g. a browser) can cache web content(e.g. an HTML file) ignoring query strings.
For example, a browser requests https://a.com/a.html?query=1, then requests https://a.com/a.html?query=2. Is it possible the browser just ignore "?query=2" and get result from cache?
I believe you would be able to do this, if you write a Service Worker that takes advantage of the Cache API.
I need to automate a long list of tasks using post requests.
I need to make a payment, and I want to use only http requests.
I cannot use headless browsers or anything that actively interacts with a browser, so please do not suggest that. I will use JSoup. (Why? I need to run multiple tasks, and headless browsers are too heavy).
The website has different steps to accomplish the task. The problem here is that the website sends a lot of different gibberish requests to various websites, and I have no idea on what I can manipulate/need to send.
For example, by using firefox's built in network tool, I can clearly see that there are a lot of different cookies, and those cookies actually change every time another request is sent.
Example:
Task on page 1:
Request cookie: cookievalue1
Response cookie: cookievalue1
Task on page 2:
Request cookie: cookievalue2
Response cookie: cookievalue2
Where does the browser get the cookie on task 2? Why does the server respond with the same cookie?
How should I automate this task? I have no idea even where to start.
Are there some specific things that I need to look out for?
I need to know which requests a webpage sends. Basically the site i call, calls another service/api/url whatever and receives the data (probably within javascript) and show me this. Can i see all the calls it make?
Edit: concrete example:
From this site (http://www.flickriver.com/lenses/nikon/) you can choose a lens, at that moment, the page sends a request to flickr, and get all the data. But in chrome developer tools i could not see this request.
Here is a screenshot of get requests. I have looked through them but could not see any request to flickr.
The first is request to the page. And the sixth one is the picture request already, where it requests the picture by its id. So in between other 4 requests should contain a request to the external source which gives the picture id in return or do i miss sth?
And what if the backend makes this request? Do i still need to see this request in developer tools?
No, of course you cannot see the calls made by some server to another server. Why would you expect to be able to do that? Those calls have nothing to do with the browser. The browser knows nothing about those requests. The browser knows only about requests that it itself initiated. Devtools can only report on requests made by the browser. If in fact there were some way to spy on the requests made by a server to another server, it would be gaping security hole.
I'm trying to understand how an IIS server handles different browsers in the header of an HTTP request.
The situation is that I have some load tests set up that fire off HTTP requests to an IIS server, constructing them and sending them over the wire. My code allows me to specify the browser in the header, but I'm not sure what that would actually change.
So what does IIS do with that particular information in the header?
As far as i am aware IIS doesn't actually do anything with the header.
You can create rules to explicitly handle a type of browser, this is pretty useful if you block traffic from countries but you still want to allow bots for example.
Its useful to also have this information in Log Files too
I have an ASP MVC3 website with a rest API service.
When a user passes in an invalid API or they have been blacklisted i wish to ignore the response.
I know I could send back a 404 or pass back an 503 but if someone keeps polling me then I would ideally like to ignore the response causing a time-out their end. Thus delaying the hammering my server gets.
Is this possible within ASP.net MVC3? If so any help would be most appreciated.
Thank you
For what you want, you still need to parse the request, so it will always consume server resources, specially if you have an annoying user sending a query every 500ms...
In this situations you would block the IP / Header of the request for a period of, for example 10 minutes, but it would be a very good idea to block it on your load balancer and prevent that request that even reach your application, this is easily accomplish if you're using Amazon Services to run your Service, but all other cloud provider do support this as well, if by any means you are using a cloud hosting.
if you can only use your web application, and this is a solution that is not tested, you could add an ignored route to your routing mechanism like:
routes.IgnoreRoute("{*allignore}", new {allignore=#".*\.ignore(/.*)?"});
and upon check that the IP is banned, simple redirect using for example Response.Redirect() to your site, to a .ignore path... or, why not redirecting that request to google.com just for the fun of it?