Time gap between .favicon and all all other requests? - html

We're seeing a consistent pattern across speed tests on GT Metrix for a site where there is a 150-250ms gap between all resources loading and then the favicon request initializing. This is extending the fully loaded time.
Any ideas why this might be happenening?
Favicon is referenced in the head of the HTML file as follows:
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
The Drupal 7 .htaccess file refers to favicon as follows:
# Pass all requests not referring directly to files in the filesystem to
# index.php. Clean URLs are handled in drupal_environment_initialize().
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]
Screenshot of waterfall (note gap between penultimate and last request):

This is because the favicon is not needed to actually render the page, only to display in the title bar, so browsers postpone downloading it.
(I'm curious myself if it can be force-loaded quicker, apparently it's not trivial at all, even with preload or http/2 push it would just be loaded twice)

Related

Firefox uses wrong urls

I coded a webpage. At all sites I have to include several files via HTML. These files are stylesheets, images, javascripts and so on.
My big problem is Firefox. If I open the main page (https://www.example.de/) in any browser everything works fine. If I open a subpage (https://www.example.de/sub_page) of the webpage in Microsoft Edge, Chrome, Safari and a few other browsers everything displays as it should. Only in Firefox the subpage completly displays incorrect. Over the network tab I found out that these files are not loaded, because Firefox uses wrong urls for the files I have to include.
For example:
Included JS:
<script src="./scripts/main.js"></script>
Expected example-URL (Used URL in all other browsers):
https://www.example.de/scripts/main.js
Used example-URL only by Firefox:
https://www.example.de/subpage/scripts/main.js
And that last one is a wrong url. The first one is correct.
The subpage file is in the same directory as the main site file and the main site file loads perfectly in Firefox with the same include-urls. So why only in Firefox the urls get like this at my subpage? Any help is highly appreciated. Please tell me if you need more examples or anything else.
EDIT:
The subpage is a single php file and not in a extra folder. .htaccess edits the urls on the whole site. It is looking like this:
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [NC,L]
ErrorDocument 400 ./404.php
Best regards,
Filip.

SSL-certificate; Green lock is sometimes not displaying

I have a website that has an SSL-certificate. When I enter the homepage everything is correct and a green lock is displayed in the url, see my website here.
The issue is that this lock is not being displayed on some pages. Here is an image of it.
How can I assure that the green lock is being displayed on ALL pages on the website?
I have noticed that when I insert the website that doesn't have the green look at first the look appears while the website is loading and after finished loading it disappears.
EDIT 1, the code below is used to re-write all URLS with www to "https://". This one I have implemented into my .htacess-file.
RewriteEngine On
# If not using www
RewriteCond %{HTTP_HOST} !^www.(.*)$ [NC]
RewriteCond %{HTTP:HTTPS} !on
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [R,L]
# If using www
RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
RewriteCond %{HTTP:HTTPS} !on
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
Problem solved by using this plugin https://wordpress.org/support/plugin/wordpress-https
Can anyone sudgest me how to solve my problem without using the plugin maybe? Somehow some URLs are not being updated.... any idea on how to do it manually instead of using plugin?
My best guess would be that your page contains some non-https content.
Add Following meta value to your header. Basically it will force non HTTPS to use HTTPS secure connection url.
If you want to allow the Mixed Content request, then add the below tag into tag.
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
If you want to block then add the below tag into the tag
<meta http-equiv="Content-Security-Policy" content="block-all-mixed-content">

Problems with CSS while using RewriteRule on .htaccess

I'm having some trouble while using RewriteRule on my local and remote servers.
Here's the situation I'm in right now:
localhost/puntvallesgit/index.php?seccion=nosaltres
this is the actual URL
I want it to be renamed to:
localhost/puntvallesgit/nosaltres
and
localhost/puntvallesgit/nosaltres/
Both urls work, meaning, it does not give me a 404 or something like that, but, with the second one (localhost/puntvallesgit/nosaltres/) there's no CSS nor JS loading correctly.
Looking the html code, I can see that while using the rule, the url path for JS and CSS gets changed to:
localhost/puntvallesgit/nosaltres/css/styles.css
yet the code itself has this:
<link href="./css/styles.css" rel="stylesheet">
I understand that sine I'm rewritting the url, to /nosaltres ... the html code adapts to that new folder structure, but that is not the expected behaviour.
Also, while using the url without the final slash (localhost/puntvallesgit/nosaltres) it works great (under localhost).
I could use absolute paths, yet, that is not the most ideal thing to do, since then paths would change from my localhost to my remote server
Here's the htaccess rewrite i'm using:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^([^/]*)$ index.php?seccion=$1 [NC]
RewriteRule ^([^/]*)/$ index.php?seccion=$1 [NC]
</IfModule>
Some advice please?
Thanks in advance
You can add the base tag between the <head> </head> section of your site. Then your asset folders will read from the root.
<base href="/">
Also rewritecond only works for the first rewrite following it. You can condense your rule this way.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^([^/]*)/?$ index.php?seccion=$1 [NC,L]
</IfModule>
This is not htaccess related (although your rewrite rules are not optimal), but rather a problem in the way you load your stylesheet.
When browsing to http://localhost/puntvallesgit/nosaltres/, the browser will try to load your stylesheet from ./css/styles.css which translates to http://localhost/puntvallesgit/nosaltres/css/styles.css, while your stylesheet is probably at http://localhost/puntvallesgit/css/styles.css.
You should use /puntvallesgit/css/styles.css as the source of your stylesheet instead.

htaccess rewriting twice in CHROME

I have the following in my htaccess so i can access the page as via domain.com/whatever instead of domain.com/index.php/view/whatever. So this removes index.php/view from the URL. This is working fine in all browser except chrome. Chrome is rewriting the page twice. The way i noticed this is because i have a counter on the page. Everytime the page load, the counter gets incremented by 2. If i remove the rewrite rule then counter works properly and increments by 1. Why is the rewrite happening twice in chrome. Firefox and IE loads the page only once like it should.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/view/$1 [L]
PS: view and whatever are neither files not folders. They are dynamically generated.
Nothing wrong with your htaccess. Make sure you have a valid favicon on your page. This drove me insane once and took me a while to figure out.
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">

Favicon not showing, .htaccess to blame?

I'm having problems getting a favicon to work for my website.
I've got two domains pointing to one hosting account, one points to the root and the other (the one I'm talking about here) to a folder on the root.
They both have .htaccess files to deal with 404 requests, shortening the url and redirecting favicon requests. I'm using .htaccess files because it's relatively easy to do for me (I don't have the time to be changing it to something else).
But this website, the one in a folder on the root, won't show the favicon. Everything is in place as it should be. But it just doesn't show a favicon when I go on to it.
Here's the bit of html:
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
Here is the .htaccess file:
ErrorDocument 404 /404.php
RewriteEngine On
RewriteCond %{HTTP_HOST} !^getfilm.co.uk$ [NC]
RewriteRule ^(.*)$ http://getfilm.co.uk/$1 [L,R=301]
<ifmodule mod_rewrite.c>
RewriteCond %{REQUEST_URI} !^/favicon\.ico [NC]
RewriteCond %{REQUEST_URI} favicon\.ico [NC]
RewriteRule (.*) http://getfilm.co.uk/favicon.ico [R=301,L]
</ifmodule>
if you write href="favicon.ico" it means, your icon is located beside your page. if your page is in other folder you need to address the folder/icon.ico