When we have an update on the React app while the browser is rendering the cached image of the app, how can we make the browser to pick the updates immediately — without having to hard refresh your browser.
Related
We have an ember single page application. On a specific page, while clicking on a hyperlink, I want to open a specific route in the new window.
The problem here is, it starts downloading all the js files (main.js) and authenticating the session and then only it is loading the route. This is taking too much time and giving a poor user experience. Since the hyperlink can be clicked only when the user is already logged in, is there a way to avoid downloading all the js files and authentication in ember? Something like a child window of the current window, so that the route will be loaded immediately.
is there a way to avoid downloading all the js files
They should be cached by the browser unless you have your server set headers to not cache your JS files.
But maybe the files are loaded from cache but the delay you are experiencing is the parsing and execution of your scripts. This cannot be avoided with a SPA.
You could shorten the perceived delay by using server side rendering via FastBoot. This will mean the route is immediately rendered, but the user won't be able to interact with it fully until all of the client-side scripts have been executed.
authentication in ember
I don't think this adds much delay as it should just be checking a cookie or HTTP header as you are already authenticated in another window.
Something like a child window of the current window, so that the route will be loaded immediately.
As you have a SPA, you should try to avoid opening a new window as everything is already loaded in the current one. And the user can easily return to the previous page via the browser back button and this too should be almost instantaneous.
Is there a particular business reason why it has to be in a new window?
I'm building an Ionic application, I have built 50% of the project, and at first I used the sidemenu template that is auto generated with ionic start MyProject sidemenu, and then I added my own pages and components after that.
In the browser view the app was great, then I deployed my application to an android device, with the deployment being successfully When I start the application I felt that the application was slow, but when I switch to a some view, it took 5-10 seconds to open the new page.
I watched the traffic between the server side and the application, and observed that the application is not switching to the new page until the request is back and the view is rendered!
any help?
Try switching to your views first and then using the ionViewWillEnter() or another built in ionic API for the application lifecycle.
ionViewWillEnter will pull the data everytime the view loads, where
ionViewDidLoad will pull the page on first load only.
ionViewDidLoad() {
console.log('ionViewDidLoad SplashPage');
}
You do not state which version of ionic you are using but in ionic 3 if you create your pages with the terminal using
ionic g page MyPage
It will automatically create the page as a module. This allows for lazy loading. You can read more on it here form ionic's official blog post.
Its hard to say exactly why the view is only loading after it hits the server as you have not added your navigational code. There could be a code block that waits for a server response before pushing to the next page.
If your view is depended on received data from the server then your request should be in a new Promise allowing you to add conditionals for before and/or after the data has been touched.
I am just curious to know how these websites were made to load only once. If you go to the sites http://fueled.com/ or http://ecap.co.nz/, the browser shows the spinning wheel only the first time the website is loaded. When you navigate to other pages from the navigation menu, like About or Contact or Team, when those pages load, the browser doesn't show the spinning wheel.
How do they make them work like this?
It is because page load is not triggered upon those links. Instead, a post request is triggered and its response will be used. Also, further page loads will be quicker, since scripts, styles and pictures will be cached, that is, saved locally on your computer.
You can check what happens using the browser console's network tab. Click on the last request before you click on such a link. You will see that the request log will not be cleared, but other requests are added. That means there is no page load in the meantime.
I am developing a Chrome app that shows some web content in a webview tag. The content is being cached. When I edit the content files, clearing Chrome browsers' cache does not seem to actually clear the webview cache.
One of the posts recommends to assign a unique partition ID every time Chrome app starts.
Changing partition ID on the webview does help to clear (or re allocate) the cache, but I still would like to take advantage of caching 3MB of web content and clear it manually only if it changes.
Is there a way to clear that cache, in particular on Chrome OS?
This has since been implemented and is available in Chrome 43+
webviewElement.clearData({}, {cache: true}, function() {
// Cache cleared
});
I saw this question asked here 18 months ago, but without (a correct) answer: Window like facebook chat
Both Facebook and OkCupid have messaging windows which stay open even when you click to another page on their website. Literally the IM window (and friend list, on Facebook) don't so much as flash or "blink" as if they were reloading quickly. If you refresh the website (F5 or such) then the messages will disappear, at least for a moment.
The only thing I can think of is that the entire website never actually changes addresses, but just pushes the new URLs to your browser so it looks like the URL changed, but you never really left the same file.
How are they offering this persistent chat?
My guess is they are using something similar to qjuery-pjax:
https://github.com/defunkt/jquery-pjax
From their docs:
pjax works by grabbing html from your server via ajax and replacing the content of a container on your page with the ajax'd html. It then updates the browser's current url using pushState without reloading your page's layout or any resources (js, css), giving the appearance of a fast, full page load. But really it's just ajax and pushState.
This means clicking a link on the page will load only part for page and leave the chat windows untouched (no flicker). If you hit F5, the browser is initiating the refresh which will not use ajax/pushState. This causes the chat windows to flicker.