everytime favicon loads, browser loading old one initially and then new one - ruby-on-rails

In my rails app, I am managing two favicons based on a condition.
Below is the code in my application layout
- if <condition>
= favicon_link_tag "favicon1.ico"
- else
= favicon_link_tag "favicon2.ico"
Its working fine as per condition but when I switch from favicon1 to favicon2, on page load browser loading favicon1 initially and then loading favicon2, and same is happending whenever favicon is loading in browser.
Browser: Chrome
Version: 105.0.5195.102 (Official Build) (x86_64)
Browser is not sending two requests
Browser cache enabled, but even if I disable it, issue still occurs.
My suspicion is that, when I click on any link in my app, browser is requesting for favicon, until the response comes back, browser loads previous favicon and once the response comes back, loads the correct favicon.
Browser is not requesting favicon everytime when I click a link but it's calling randomly and requesting frequently on few links.
Is there a way to stop browser from requesting favicon unless it's a whole page load?

Related

Web App Manifest: "start_url" doesn't work for Safari

The "start_url" works for Android browsers, but for iPhone, Safari always uses current page's URL and ignores the "start_url".
For example, the current page is https://test.com/index.html, on manifest the "start_url" is set to be "start_url": "index.html?flag=1", but when the page is added to home screen on Safari, it still uses https://test.com/index.html, without the parameter.
Is there a way to apply a different URL as the start up URL for Safari?
A hacky solution I've implemented here is to silently change the URL on the page you prompt the user to install the PWA with: history.pushState({}, "", "/"); (see: https://stackoverflow.com/a/56691294/827129)
This will update the URL but won't cause the page to reload or refresh the DOM, so you can see the page you're on as normal, but when the user goes to install the PWA (Add to home screen) it'll save the root URL, so that's what they'll see when they open the PWA.
Downsides here include:
the URL in the address bar will update (not a big deal on mobile)
if the user presses the back button they'll go "back" to the page you triggered the history.pushState() on, so they'll need to press back twice to actually go back
if the user refreshes the page they'll see the homepage
In my use case this is good enough, there might be extra solutions to handle these issues that could be applied on top of this solution to improve UX.
try this url format
"start_url": "./index.html?flag=1"

Permanently Redirect iOS Home Screen Web Apps

I have a single-page web app using Sencha Touch that has been added to the home screen on about 2000 iPads. I am looking to change the URL of the web app without requiring all of those users to delete the launch icon from the home screen, go to the new URL, and add it to home screen again. The app also uses a cache manifest to cache the HTML, CSS, JavaScript, and images, and the app is capable of working entirely offline.
Web pages added to home screen in iOS do seem to respond to HTTP 301 (permanent redirect) as expected, but I have found the behavior to be quirky in iOS 8 on iPad 2 devices as I will describe. I created an ASP.NET MVC website that I deploy under the same URL, replacing the Sencha Touch app in order to accomplish the permanent redirect. Here is the process I'm using and the behaviors I'm seeing:
When the app is launched from the old URL, it requests only the cache.manifest, and I return HTTP 404 to make the app stop caching.
The app loads and I have an event handler in the app's JavaScript for the applicationCache "obsolete" event that will call window.location.reload(true). The app will then reload and this time will ask for the previously cached HTML page (which is hosted at the URL root), and my ASP.NET MVC site will then return HTTP 301 to permanently redirect to the new URL.
Once the app hits the new URL, it begins downloading the resources from the cache.manifest at the new URL. I have an event handler on the "updateready" applicationCache event that will call window.location.reload(true) and reload the app. Once the app reloads, it will then request all resources (XHR requests to services) from the new URL as expected.
When I test this on an iPad 1 running iOS 5, this works exactly as I would expect. Once the resources from the new URL are downloaded and cached, it always makes every request from the new URL from that point. I can put the device in airplane mode and the app will work just fine offline.
This is where the quirky behavior begins, and I only see this on my iPads that are running iOS 8.x (I don't have any devices running iOS 6 or 7). I then close the app by pressing the home button and relaunch it from the home screen icon. When I relaunch the app, it will always initially go back to the old URL (iOS 5 always goes to the new URL), which is strange because the HTTP 301 from before should have prevented this. From here, there are two possible behaviors:
5a. Sometimes, it will ask for only the HTML page from the old URL (root URL), and in that case, it will get another HTTP 301 and will then redirect to the new URL, ask for the cache manifest, then load the app. From there and onward, it will never make requests to the old URL again when I open and close the app. When I put the device in airplane mode, the app works just fine offline. I have two iPad 2s running iOS 8.3 and 8.4, and this will happen about 50% of the time on these devices.
5b. Other times, it doesn't work so well. When relaunching the app after downloading the cached resources from the new URL, it will go back to the old URL and will not request the HTML page, and will instead request the cache.manifest along with the CSS and JavaScript. The the cache.manifest request will be result in another HTTP 404, but if I continue closing and re-opening the app, it will never consider the cache to be obsolete and will not request the HTML page again. Interestingly, I am only able to reproduce this on the iPad 2s. I have an iPad Air 1 running iOS 8.3 and I only ever see 5a on that device.
For the case described in 5b, it does request the JavaScript files. So, I went into one the JavaScript files and put in window.location.reload(true), which causes it to request the HTML page, which results in another HTTP 301. Now when this scenario occurs, it does send it to the new URL, but every time I close and re-open the app, it repeats the whole cycle. It goes to the old URL, gets the JavaScript, reloads, gets a 301, then goes to the new URL. When I put the device in airplane mode and open the app, it doesn't work.
I found that if I put the iPad 2s in airplane mode and run the app in the old URL, then run it again and do the 404 for the cache.manifest and the 301 for the HTML, then 5a will always occur. This sounds like a bug in iOS 8 (that possibly also exists in 6 and 7), and I'm trying to figure out a workaround that I can implement in my ASP.NET MVC website to redirect to the new URL that will work 100% of the time.
Any insights would be greatly appreciated.
I figured out how to avoid the quirky behavior. As I mentioned above, the app is listening to the "obsolete" event on applicationCache and is then calling window.location.reload(true) to grab the page again and get the 301. I found that if instead of reloading the same page, I redirect to a different page and back again, it works perfectly 100% of the time. It redirects to the new URL, caches the resources, then never asks for the old URL again. I also discovered that closing the app and opening it again after the cache is obsoleted has the same effect.

Chrome refuses to load some PDFs in the browser

Our web application lets users upload forms in pdf format (which are then stored in a Windows Azure Blob) and also lets them view them afterwards. What we want to is embed the pdf in a lightbox sort of thing. This is working totally fine in firefox once something like Acrobat Reader is installed but Chrome does absolutely nothing with it.
Even before getting to the embed part, just opening it in a tab doesn't work in Chrome. Entering the url in firefox works fine and it will ask if you want to save or open in Acrobat Reader. Opening a new tab in chrome and trying go to the url does absolutely nothing. The page just stays a blank white, and the name of the tab remains as 'New Tab'.
I checked what was going on in the Network tab of the browser console, and all I see is a supposedly successful GET call (code 200) but the status of it is cancelled.

firebug error - what does this mean?

I'm using the jquerymobile platform with one of my Drupal sites. It works flawlessly on my dev server, but on the live server, every time I click on a link it sticks a pound sign in and refuses to load the content of the page being linked. When I hit the browser's refresh button, the pound sign goes away, and the content does load.
Example:
Sponsors
should go to http://mysite.com/sponsors. What happens on my live site is http://mysite.com/#/sponsors. The page stalls there, but if I click reload, the # goes away and the content loads.
I have a user agent switcher in firefox, so I turned firebug on, and on the live site, I'm getting the following error every time I click a link:
"attempt to run compile-and-go script on a cleared scope"
This does not occur on the dev site. The live site is http://m.shoppersummit.com/. Any ideas why this would happen? As far as I can tell, I have the same version of jquery, jqueryui, and jquerymobile installed.
Edited to address redirect loop
I've been at work since 6:30 AM; my brain is fried. This is a drupal site, with a "real" theme and a mobile theme. The only way to view the mobile theme (which is where the error is occurring) in a desktop browser is to change your user agent string to a mobile one. There's a firefox addon that will do this. If you try to view the site with a standard desktop user agent string, you will get the redirect.
Have you tried including a target? e.g. target="_self"

Links in remote JQueryMobile sites in a PhoneGap app open safari

I'm having quite a peculiar problem with PhoneGap and JQuery Mobile, using the latest versions of both frameworks as of this writing.
My phonegap app has some pages 'local' to the app, and other pages that are loaded directly from a remote site. Going between the local and remote pages is fine (there is no transition but that can't exactly be helped). However, once I'm on the remote pages, any link I click on the remote pages opens Safari with the page I requested. This is not desirable functionality, as I would like it all to be within the UIWebView, and none of my links are marked with anything special that would cause Safari to open.
It gets weirder. If I then switch from Safari back to the program, the remote page I requested appears in the UIWebView, however pressing the back button leads me not to the first remote page, but the first local page.
The phonegap app right now is quite bare, very close to the default except with JQM css + js loaded. This happens even if I create a simple test app that has one local JQM page, one remote JQM page and then a remote page that is linked to from a JQM remote page.
I'm stumped. What's going on here?
The default behavior for PhoneGap is to open external links in Safari unless they are added to the ExternalHosts property in PhoneGap.plist.
Try adding the external hosts and PhoneGap should behave correctly and load the external locations inside of the application.
(source: tumblr.com)
Here also is a post about using iFrames and ExternalHosts that could be of some help as well.

Resources