Faster page load speed is what matters if you have online presence. There are several services available online that provides you the performance of your page. The one recommendation that you might have seen is “Serve resources from consistent URl”.
Why this recommendation appears?
There are several files associated with the website such as CSS, JS, images, and many more. Whenever the visitor opens your website the visitor’s browser requests from the server to send the files. For each file, a request is sent which means HTTP request is generated. So, as the number of HTTP requests increases the page loading time also increases. Since both of them are directly proportional to each other.
Now, sometimes what happens is that a resource is available through multiple hostnames and domains. Consequently, each time the page is loaded the resources gets called and downloaded multiple times from each of the existing URLs.
This puts a bad effect on SEO and page load timings.
How similar resource URL occurs?
There may be several reasons behind it:
- When the identical resources are shared between two or more subdomains or subdirectories of the same website or between dissimilar linked websites.
- When the same external resources or libraries are used by two or more plugins.
- It may result from incorrect indirects.
- It may also result from misconfiguration in CDN settings or bug in the theme.
How to fix the problem?
#Method 1: Move
Often inconsistent URLs are created by resources such as images, which are shared by multiple subdomains or linked sites.
For example: If your website example.com shares an image with the site division subsite.example.com. This will create two paths for the same file.
To fix the problem, serve the file from single hostname, instead of hosting it from the same website and its subdivision. That is, there is a need to host it on. To illustrate, example.com link to it from subsite.example.com
This solution also brings benefit when two separate domains are used and works efficiently when they are linked. Although there is a need for additional DNS lookups everytime but the advantage of caching make it worth. It is noteworthy that a DNS lookup will be anyway required due to linking of two sites.
#Method 2: Rewrite
Duplicate resources are also generated when sometimes is used to speed up the website. This happens by the way in which plugins and themes handle static resources.
Normally all the media files are moved to the CDN by editing all the static resources URLs manually by using a plugin or creating a C name.
While this works seamlessly, but your plugin or theme can pull some files, for instance, site’s logo into the site’s code and out of the media library.
Therefore, the same files are served from your domain (files pulled into theme settings) and CDN (the media library).
To fix this problem, change the file path in theme’s file. This is done to point to the file on the CDN. This may vary from theme to theme.
The logo settings are mostly available in the file names header.php. Search line that defines the logo path and match it with the CDN resource URL. Use child theme to make the necessary changes in the theme file.
To ensure all the links are consistent it is better to use a plugin Better Searcch and Replace.
#Method 3: Redirect
When the site exist at www.newsite.com and newsite.com or you have hosted different versions of site on two seperate address. This results in duplicate resources. There may be some practical reason for doing so, but in reality you end up having two websites, one that exists at the root of the domain and other hosted at the subdomain www.
Consequently, having two websites that are deeply connected but end up with duplicate results.
Here you are advised to select the preferred version and then apply the 301 redirects. The 301 redirect ensures that browser and search engines will skip all other versions and go to the preferred version of resources and pages.
One can also use 302 redirects, which is used when one’s website is still developing and changing. This redirects instructs that resources have temporarily been moved.
#Method 4: Canonical Tag
The issue can also be fixed by using canonical tags. But it should not be preferred first, unless 301 and 302 serves the purpose. These tags does not eliminate the problem but only instructs the search engines to prefer certain version.
One should use these tags only when the 301 and 302 cannot be applied.
Add the link to the preferred resource with rel = canonical attribute in the code. This can be used in a similar way across domains.
#Method 4: Plugins
There are times when usage of multiple resources result in warning of consistent URLs. This happens because multiple plugins share resources or a single plugin add a resource to the original URL.
Deactivate one of the plugin which is causing the trouble.
This article discussed all the possible ways in which consistent URL issue can be fixed to improve the page loading speed.