browser back button vs refresh button - browser

Scenario 1: let say the previous page that i visited is example.com, so if i hit the back button, the browser will load example.com
Scenario 2: let say i am currently on example.com and hit the refresh/reload button, the browser will load example.com
My question: in the browser point of view, does it differentiate the two scenario and do anything differently? is there a spec for this?
My suspicion is that the browser does differentiate these 2 scenario. In my case, example.com is a static single page react app that do fetch request onComponentDidMount. I got a Status Code: 304 Not Modified when click refresh/reload button and Status Code: 200 OK (from disk cache) when click back button.

The difference between refresh and back is that the browser understands the back button as completely new access. Refresh is something little bit different. For example, in back button result, you won't get 304 status.

Related

How would I force my page to be loaded *only* in an iframe

I want to host a webpage that can only be served via iframes within my own domain.
An example of this in the wild would be Codepen. They sandbox the content of a "pen" in an iframe, but if you try to load the url from a browser it responds with an empty page.
I understand there might be multiple answers to this question but I'm hoping someone could point me in the right direction.
Would I be checking the referrer server side? Are there any other options?
Referer is a good start for the server side.
Also you can try using CORS headers:
Only allow iframe to load content
Or validating using client side javascript code:
How to identify if a webpage is being loaded inside an iframe or directly into the browser window?
Also check info about referrerpolicy
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-referrerpolicy

Cache control header not working

I have set Cache control in my response header as Cache-Control:public, max-age=86400. But when I try to refresh page or open a new tab, it always hits my server. The response status I got is 200, server log is appeared for this request also I checked chrome://cache/ this request is not in the list. I already looked some similar SO questions cache-control not working without etag and why cache-control:max-age don't work?. But still with no luck. Tested on chrome 56.
Chrome disables cache when DevTools is open, or at least it does Chrome 59. Open DevTools, go to Network, uncheck "Disable cache" at the top. Now you should be able to refresh the page and see it in chrome://cache.
Cache control tells your browser (and proxy servers like Squid) what resources it cannot cache. But it does not force your browser to cache a resource.
I recommend to check the error_logs to see if you really go to the backend, or stay in the browser.
In my case, browser gives me 200OK in the console logs but I don't reach the back end according to the error_log ...
Cache-Control response header will not work for page refresh. Try making that request twice without refreshing the page, then you will see it being cached (the request won't reach your server internally).
To achieve what you want you might have to cache your request by accessing localStorage, or just cache it through a back-end caching library.

Webpage load time issue. wget showing "HTTP request sent, awaiting response... 301 Moved Permanently"

I have two websites on the same server. Both use Magento template. I am bit confused about the load time of both.
Please see the image.! http://i.imgur.com/iZeqa6R.png
They both use same DNS server and the above result is from the server itself.
One is loading in 5-6 sec but other take more than 10 sec.
What is mean by "HTTP request sent, awaiting response... 301 Moved Permanently". Is that causing the issue?
If you are getting a "301 Moved Permanently" then one of the resources of your page is being returned with a header that is a permanent redirect to another server (http://en.wikipedia.org/wiki/List_of_HTTP_status_codes).
Note that that could be caused by a component that you have little control over such as a framework or and widget that is coming from a CDN like jQuery, webfonts, bootstrap, social widgets, etc.
To find the offending resource, first clear your browser cache, then open the Developer Tools of your browser of choice, open the Network tab, then reload the page. Scroll through the resources and it should be obvious which is causing the delay and/or redirect.

Browser refresh in MVC application

I have an MVC 5 application with multiple controllers and multiple views(Controller1 with action1(associated view1) and Controller2 with action2(associated view2)). I defined Controller1 and action1 as default in RouteConfig.cs. The default url I see in the address bar is when I run the applicaiton from IIS is
http://andem.sunquestinfo.com/dxp"
I do not see the controller or action name. I navigate to view2 and see the View2 contents and the url in the address bar remains the same. Now if I refresh the page (either by F5 or browser refresh icon) I am redirected to view1 and the url doesn't change.
I tried using custom ActionFilterAttribute, but on F5 Request.Url is
"http://andem.sunquestinfo.com/dxp"
Please suggest why the controller and action name are not shown in the url and how I detect browser refresh.
Thank you
MA
Well one thing for sure is you cannot detect browser refresh server side, for the server its just another request/response cycle that gets triggered.
No you dont see the controller or action when you debug the application because it navigates to the root of your site, and you have configured your routing to default to a certain controller/action when it doesnt receive this info explicitly.
As to why the url doesn't change when you navigate to view2 its hard to tell because I dont know exactly how you navigate to it

How can I configure IIS to use customerrors with option set to recreate for all extensions/MIMEs?

I'm currently using customErrors, and I would like to use the recreate option, always.
This currently works for URLs such as
mysite.com/asdf
My custom error page loads as this URL:
mysite.com/asdf
However, this is not working for URLs such as
mysite.com/asdf.aspx
My custom error page loads as
mysite.com/mycustomerrorpage.aspx?errorpath=/asdf.aspx
This is handled by IIS as a 302 redirect to the error page above with a status of 200 when it loads.
What I'm trying to accomplish: I want the user to receive an http status of 404 (or respective status code), and I want the page to recreate always (regardless of extension or lack of extension). I do not want a 302 redirect from IIS, and I do not want the custom error page to return as a 200.
I'm new to IIS - This seems like it would be a basic thing, but I'm having more troubles than I would've guessed :)
Thank you in advance for any assistance!

Resources