Part of CSS and JS theme files not serving from CDN
-
Hello again,
I configured Amazon CDN with w3 total cache. Seems to work but only about half of my theme files is served from the CDN (https://gtmetrix.com/reports/www.protestkit.eu/j5xAFt4o/). I tried reaching to theme support about that but they don’t seem to know, no answer there. Is this supposed to be happening, and if not, how can I add other files to the CDN?
I tried adding to the customs files list:
{wp-content_dir}/themes/themify-shoppe/themify/js/*
It didnt work but I guess that list is for files outside of theme, so shouldn’t make a difference anyway.
my config: https://mega.nz/file/1J5k3BqT#snkBg5834AVRFXe95WoTXDEs6FKPgymus4qj0b_Er-c
Thank you in advance for any guidance
The page I need help with: [log in to see the link]
-
Hello @sinorgpl
Thank you for your inquiry and I am happy to assist you with this.
I’ve checked your website and as I can see those files are uploaded to CDN.
For examplehttps://www.protestkit.eu/wp-content/themes/themify-shoppe/js/themify.script.js?ver=5.1.7
as GtMetrix suggests is uploaded to the CDNhttps://cdn.protestkit.eu/wp-content/themes/themify-shoppe/js/themify.script.js?ver=5.1.7
You should visit the page as logged in. This way you will find out which URLs are used by that page and queue the upload process of those URLs.
Go to the backend and check that the upload queue is empty. If not – process it.
visit the page as logged in again. It should use CDN URLs now.
Now you can purge page cache and visit it as an anonymous user to check that CDN URLs are used by page cached version too.
I hope this helps!
Thanks!Thank you for the response!
Indeed some files load first from CDN, then again from my server. Why is that? Shouldn’t they just load once?
Then it doesn’t apply to all anyway, for example https://www.protestkit.eu/wp-content/themes/themify-shoppe/js/modules/wc/ajax_to_cart.js?ver=5.1.7 doesn’t load from CDN at all.
Now what do you mean by “visit the page as logged in. This way you will find out which URLs are used by that page and queue the upload process of those URLs.”?
– what page?
– what urls?
– how to que the upload process of those URLs?“Go to the backend and check that the upload queue is empty.”
Are you refering to the button to check CDN distribution status?I tried googling but I’m still lost. Thank you for your time.
- This reply was modified 3 years, 10 months ago by sinorgpl.
Hello @sinorgpl
Thank you for the info.
As I’ve mentioned those files are not being served from the CDN at the moment, however, they are uploaded to the CDN. https://cdn.protestkit.eu/wp-content/themes/themify-shoppe/js/modules/wc/ajax_to_cart.js?ver=5.1.7
Make sure to purge the cache and purge the CDN.
Make sure to check the unsuccessful transfer queue.
POssibly try to use the Purge button and manually add the paths of the files that are showing not being served from the CDN.
Thanks!Ok thank you, I understand now the general instructions but I still can’t find the “unsuccessful transfer queue”. Would there be some sort of popup if there were any transfer failures?
Hello @sinorgpl,
If there is no “unsuccessful transfer queue” it means that all files are uploaded and since you are using Origin Pull there should be no unsuccessful transfer queue,
SO you either ned to purge the page cache so you can see the correct URL’s and or purge the CDN.
Also, make sure you are not using some other caching solution or another caching level like server side caching or possibly some proxy.
Thanks!Thank you for the clarification, that was really helpfull, but I’m still struggling.
– I did have server side caching enabled in my server provide panel, I probably wrongly assumed that w3 total cache would take over it. I now disabled it but my GTMetrix / CDN result is the same. I can keep w3 total cache page caching enabled, right?
– I purge w3 cache religiously but it doesn’t change anything with this issue
– I purged CDN completely a few times as well, no change eitherI now tried adding files individually to customs file list, like this:
{wp-content_dir}/wp-content/themes/themify-shoppe/js/themify.script.js?ver=5.1.7
But I still see my page loading first CDN, then my server:
https://www.protestkit.eu/wp-content/themes/themify-shoppe/js/themify.script.js?ver=5.1.7
Am I doing something wrong?
Thank you for your patience and support
- This reply was modified 3 years, 10 months ago by sinorgpl.
Hello @sinorgpl
Thank you for the information.
In some cases, even tho the files are uploaded to the CDN the HTML output is showing them as served from the Server.
URLs got to the page via some non-regular way. the plugin does the best but may not know code business logic and there are still cases when code will “win” and put the original URL on the page.
e.g. from javascript code when URL is concatenated, or coming from ajax response when URLs don’t pass filter.
Thanks!Thank you, I understand.
Do you think that I should try another plugin to implement CDN? Would official amazon plugin be compatibile with w3 total cache?
Or is this rather something with my theme? I already reached out to my theme support about this but they are avoiding an answer so I’m looking for more clues.
Hello, I have update from Themify support:
Hi,
I see the issue on your website, the files are loading twice since there’s a <preload> tag that uses the CDN, but the actual script path is not updated, thus it loads from the main site.
I believe the reason for this issue is that the plugin is not recognizing “escaped” URLs in the page, for example that themify.script.js file, to load that in the theme this is added to the page:“theme_js”:”https:\/\/www.protestkit.eu\/wp-content\/themes\/themify-shoppe\/js\/themify.script.js”
The plugin is not finding it in order to update and change it to the CDN.Can you please contact the plugin’s developers and forward them the above information? If necessary we’d happy to cooperate to resolve this issue.
Please do let us know of their response.
Thank you.I feel like this might be repeating what you already said, but Themify support are really nice hard working people, they will fix if it’s their fault, as soon as we find the exact bug together.
Thank you for your time and help, it’s really appreciated!
- This reply was modified 3 years, 10 months ago by sinorgpl.
Hello, so what do you think, is this a w3 total cache problem? I know now we are having the holiday break so no rush, just wondering what’s up since I see other threads getting solved. thank you for your time and help
Hello @sinorgpl
Sorry for the late reply.
The URLs got to the page in some non-regular way. The plugin does the best but may not know code business logic and there are still cases when code will “win” and put the original URL on the page.
e.g. from javascript code when URL is concatenated or coming from ajax response when URLs don’t pass filter.
In cases like this, which is a specific case for your environment, I can only suggest our premium service to suggest a solution for this specific environment-related issue.
Thanks!Alright, one more question – if I use a full site CDN via CNAME instead of using the CDN within w3 plugin, should that solve my issue?
- This reply was modified 3 years, 10 months ago by sinorgpl.
Hello @sinorgpl
You are most welcome.
Possibly it may solve the problem, however, I cannot confirm this 100%.
If you are referring to Full site delivered (meaning your entire website will be served from the CDN) then yes, in this case, there will be no need for the URL rewriting.
We do recommend Stackpath for CDN service and Full site delivery as it proved the most reliable and best performance.
Thanks!
- The topic ‘Part of CSS and JS theme files not serving from CDN’ is closed to new replies.