Page not updating when hitting back button, after submitting form in POST request - browser-cache

I have a simple test web site with 2 different pages, Page1 and Page2. Pages are generated by a web server.
All responses contain these headers:
Cache-control: no-cache, no-store, must-revalidate
Pragma: no-cache
Page1 contains a link to Page2 and a TextArea element, enclosed in a FORM tag. Page2 is a blank page (it doesn't contain anything useful).
Clicking on the Page2 link (inside Page1) will submit the form (and TextArea value) to the server and switch to Page2.
Each time Page1 is requested from the server, a new line is added to the TextArea. This happens at server-side (no DOM manipulation via JavaScript, at browser side).
So, when application starts, Page1's TextArea contains:
"Line 1"
If I click on the link to Page2 and then hit the back button, Page1's TextArea now contains 2 lines, as expected:
"Line 1"
"Line 2"
This shows 2 things:
BFCache (Back-Forward cache) is not being used (because each time the back button is hit, a new request is sent to the web server). It can also be confirmed by the fact that pageshow's event parameter persisted property is false.
The browser is updating the page correctly (because new content added to the page, at server-side, is being shown at browser side, as expected)
However, if I clear the text area, click on the same link to Page2 and then hit the back button, the TextArea will still show an empty content. I would expect it to show exactly one line of text (inserted by the server). This happens in all tested browsers, including WebKit, FireFox and even Internet Explorer.
Using Network tab from Developer Tools I can see that the server responds with the correct content and the preview sub-tab (in dev tools/network) shows exactly that.
So, in the second scenario, the browser is definitely retrieving the updated content from server, but refuses to update the page with that content. Seems to me that whenever the page is submitted, the browser will use the submitted page when the user hits the back button, regardless of content updated at server-side.
This issue is very similar to another here: How to prevent content being displayed from Back-Forward cache in Firefox?
with same symptoms but in that case there is no form submit and change in response headers would fix it.
My questions:
a) Why browsers retrieve an updated content from the server but don't use it to update the page in that particular scenario? Is it a documented behavior?
b) Is there a way to change this behavior? I'm particularly thinking about a way to force the browser to update the page with the response from the server (the same way it occurs when no submitting is involved).
BTW, submitting the form in an AJAX request is not a solution but merely a workaround for this issue, having in mind that a full post back may be needed in some scenarios.

Related

"This content cannot be displyed in a frame" displayed after a period of time

I have a vendor web application that sits within a frame being viewed with IE 11 on both Wondow7 and Windows 10. Emulation mode is set as default (Edge). The application functions properly most of the time. However, the application will randomly displays the error page "This content cannot be displayed in a frame". The headers being set are:
X-Frame-Options: SAMEORIGIN
X-Powered-By: Servlet/3.1
X-XXS-Protection: 1; mode-block
All content is coming from the same domain.
Everything I found on this topic so far relates to an issue occurring when the page is initially loaded not at some random point in time after page load. It also seems to occur not when the user is on the page but when they shift focus to another page or browser tab then return.
Any Ideas?
You could try to change the X-XSS-Protection value to 0. From this answer, we can see that:
The token mode=block will prevent browser (IE8+ and Webkit browsers) to render pages (instead of sanitizing) if a potential XSS reflection (= non-persistent) attack is detected.
So this might be the reason why the content can't be displayed sometimes.
Besides, if you're trying to open HTTPS page from non SSL site, you can also get this kind of error. You could refer to this thread.

CRM 2013 WebResource IFrame

I have an HTML web resource in an opportunity that produces a css tab control containing all children opportunity to the current record.
I do this through Ajax and javascript and everything works fine, a new tab is made for each child and it shows an opportunity record inside; the only issue is that it will only show the current record inside of this tab - effectively creating an endless loop.
If I paste the URL from the IFrame into the browser it shows the proper record using the right form that I specify(one that doesn't contain another web resource).
Does anyone know why it wouldn't show the same form as it navigates to? If I try google.com it works, just not for this URL:
http://server/CRM/main.aspx?etn=opportunity&pagetype=entityrecord&navbar=off&id=%7B"+val.OpportunityId+"%7D&extraqs=formid%3DC1EC704C-D29B-4786-806F-195D0A80CF07%0D%0A#255409204
Try constructing the URL with this format:
http://server/CRM/main.aspx?etc=3&extraqs=formid%3dC1EC704C-D29B-4786-806F-195Dā€Œā€‹0A80CF07%7d&id=%7b<EnterOppIdHere>%7d&pagetype=entityrecord
Use the Entity Type Code (etc parameter) instead of the Name (etn) and note that everything after that should be part of the extraqs parameter.

Opening an XPage (single page application) to a specific anchor (appPage) for unauthenticated users

I have a mobile XPages application which uses the single page application control (xe:singlePageApp) of the XPages extension library. The application also uses a workflow engine which sends out emails with links to documents to users so they can approve requests.
The link URL is composed like
http://hostname/app.nsf/m_page.xsp?action=openDocument&documentId=2A2A#requestForm
where requestForm is the name of the appPage containing the form to display a single request document.
If the user is already logged in, the browser opens and displays the document as intended.
However, if the user is not already logged in, the Domino login form is displayed (session based authentication). When the user then logs in, the same XPage is opened, but to the default page (selectedPageName attribute of the singlePageApp) instead of the appPage with the pageName requestForm. The reason for this behavior is that after submitting the login form the anchor part (#requestForm) is no longer present in the URL the browser is redirected to because the #requestForm-part is never sent to the server where the redirect URL is computed in the first place.
Possible solutions I can think of are
put the intended pageName in a real URL parameter (like documentId), parse the URL and modify the browser location (from ...&documentId=2A2A&pageName=requestForm to ...&documentId=2A2A#requestForm)
check the URL for the existence of the documentId parameter and modify the browser location (add #requestForm) if it is present
modify the Domino login form as per Jake Howlett's Suggestion (which is a not always permitted)
I was wondering now if there are more elegant solutions to this.
I would take the first option in your case. But instead of handling the url change at the client-side, I would handle this on the server-side. Otherwise, client will load the initial page once and submit an additional request to the server.
On the beforePageLoad event:
var url:XSPUrl=context.getUrl();
if(url.hasParameter("pageName")) {
var pageName=url.getParameter("pageName");
url.removeParameter("pageName");
facesContext.getExternalContext().redirect(url.toString()+"#"+pageName)
}
This will do the redirection before loading the page.

How can I clear the PropertyModel's value when I hit back on my browser

I have a DropDownChoice with a PropertyModel in my page and I have some other actions which take me to different pages. Now when I click on the Back Arrow on my browser, I come to my page which has the DropDownChoice with the previously selected choice. I understand PropertyModel holds the value for me. But how can I get rid of it when I hit Back button and why is the onBeforeRender(both on the class as well the Component) not working when I hit the Back button. Please comment if my explanation is not clear enough. I am using Wicket 1.4.8
onBeforeRender doesn't work because it's never called. When you navigating using "Back" button, no new request are sended to your server, hence page rendering never occurs. The only way to solve your problem - is to use javascript.

Automatic Webpage Data Entry based on The Page Content

Is it possible to make a program that open a page (as if a bookmark file were opened by IE), and based on its content generate a feedback, that should be fedback in a textbox on said page by pressing a button on said page?
I need this program to execute on a set time schedule to feed some data to a web server based on time dependent web page data.
Yes, that is possible. It is generally called screen scraping. You basically retrieve the web page in question via a HTTP request, parse/analyze the page you got, then send back the data that should go into the textbox (again a HTTP request).
There are libraries to do that. Here is an article describing an example in Perl:
http://www.perl.com/pub/a/2003/01/22/mechanize.html