-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stylesheet not loading sometimes on some posts #69
Comments
This is certainly related to a mixed content situation where the cache was produced by an http request and then reused in an https request. See issue #67. To prevent that, you need to force https, either using a plugin or a rewrite rule in your .htaccess file. |
Thanks for the reply, @benoitchantre When this happened the FIRST time, my site was only http :) Recently I changed to https. I have already done what you suggested. Still the same problem. |
When this happen, open the web inspector of your browser and report back the errors. |
I deactivated the plugin right after my previous reply. I just activated it again. Since the issue shows up randomly, I will have to wait until it shows up and then I will be back with the info you asked. Thanks again so much. Appreciate your time and help |
Did you verify that your https redirect work properly? This tool is great https://httpstatus.io |
Meanwhile, let me ask you if this may be cause of the issue. I use child theme. And, I use this method the of Justin Tadlock to enqueue the style: http://justintadlock.com/archives/2014/11/03/loading-parent-styles-for-child-themes Do you think this might be causing the issue? |
When I test http://www.example.org/ I get: FYI, My site works fine, NO error in Google Search Console As I mentioned before, this issue first showed up when my site was even plain http |
This is the right way to load the parent theme stylesheet. |
one page randomly up without style. Here are the errors shown in FF console: Blocked loading mixed active content “http://www.example.com/blog/wp-content/themes/CHILD THEME/style.css?ver=4.8.2” Blocked loading mixed active content “http://www.example.com/blog/wp-content/plugins/zero-spam-gur/zero-spam.min.js?ver=null” Blocked loading mixed active content “http://www.example.com/blog/wp-includes/js/comment-reply.min.js?ver=4.8.2” Loading failed for the <script> with source “http://www.example.com/blog/wp-content/plugins/zero-spam-gur/zero-spam.min.js?ver=null”. Loading failed for the <script> with source “http://www.example.com/blog/wp-includes/js/comment-reply.min.js?ver=4.8.2”. |
This is a mixed content situation, browsers don't load your assets in this situation. |
What I need to do to accomplish it? Since:
|
Check the Site Address and WordPress Address URLs under Settings > General. You should use I just submitted a fix to prevent mixed content, can you test it and let me know if it works for you? |
Thanks @benoitchantre. appreciate your sincere efforts to help. A simple thing seems to be working, at least in my case. I'm keeping eye in case the issue randomly shows up again. if does, I will be back. What I did: After reading here and there, the moved the snippet to redirect http to https RROM bottom of my .htacess to the TOP of my .htaccess. I did not change anything else. Now for couple of days I have not seen that error, YET!
No, I left it unchanged --- http Question: is it for some reason must be changed even though the redirect snippet seems to working without any problems? Thanks.
I have not tried it. |
If you use http in your settings, your images will be saved with http URLs instead of https URLs and produce mixed content. The menus items will use http and everything will rely on your redirects. Redirects are great, but they slow down the loading of your website. They should be in place, but used as a fallback. The patch only work if the settings use https. |
Great answer! Thanks @benoitchantre !
Would I still need that redirect snippet in my .htaccess if I use this patch? Thanks again! |
You should keep them, but use 301 redirects (permanent) instead of 302 (temporary) redirects. Can you remove temporary your redirects to https to test the patch? |
Yes sir. I'm going to copy the copy the raw simple-cache/inc/dropins/file-based-page-cache-functions.php file and use that one. And let you how it goes.
The code i currently have is this:
How can I modify it so it becomes 301 redirects (permanent) as you suggested? Thanks. |
Use |
Great! Thanks a lot ! |
something weird when I copy and paste simple-cache/inc/dropins/file-based-page-cache-functions.php Your raw file shows 232 lines. However, when I copy and paste, my file shows only 185 lines. Also, your raw file shows some other modifications which are not in my original file (I use version 1.6.3). Thanks. |
You can insert the following lines at the line 78. // Prevent mixed content when there's an http request but the site URL uses https
if ( ! $_SERVER['HTTPS'] && 0 === ( strpos( get_option( 'siteurl' ), 'https' ) ) ) {
$http_site_url = str_replace( 'https://', 'http://', get_option( 'siteurl' ) );
$buffer = str_replace( $http_site_url, get_option( 'siteurl' ), $buffer );
} |
Applied that patch. Also, as you suggested, changed the temporary redirect to permanent redirect. Now keep checking and let you know how it goes. Thanks. |
Applied that patch as you suggested. Also, as you suggested, changed the temporary redirect to permanent redirect. I will give you the feed back |
Thought let you know so far I have not seen any issue ! The test is based on:
|
@benoitchantre thank you for being so helpful. I'll look at the patch. |
Just to let you know, yesterday I also tested with the redirect snippet ALONE (NO patch), and did not see any issue. In other words, it's possible the the success has nothing to do with the patch. I did not test the patch without the redirect snippet. Because I was afraid Google may through bunch of 404 |
Since the redirect snippet seems to be working for me, I have removed the patch. Because, since my redirect snippet is working, I have NO way of reliably testing the patch. Thanks for your time and help |
This is a great simple plugin t use!
However, about four months ago (during 4.7 cycle), I had to deactivate it at my site.
The reason was the theme's stylesheet not working on some posts (randomly), sometimes .
Then I found out if clear the cache of “simple cache” plugins, the stylesheet begins to work fine.
I use child theme of the default twentyten theme.
Is there anyway to find out what might be causing the issue, because I would like to start using this plugin again.
Thanks
The text was updated successfully, but these errors were encountered: