https://redmine.gc.cuny.edu/https://redmine.gc.cuny.edu/favicon.ico2022-03-30T19:12:37ZCUNY Graduate Center - Project Tracking SystemCUNY Academic Commons - Support #15767: Site loading slowlyhttps://redmine.gc.cuny.edu/issues/15767?journal_id=690042022-03-30T19:12:37ZBoone Gorgesboone@gorg.es
<ul></ul><p>Yes, I can confirm that it's loading very slowly.</p>
<p>A significant part of the problem is that images on the page are embedded with URLs that look like this:<br /><a class="external" href="https://qcurban.commons.gc.cuny.edu/files/sb-instagram-feed-images/277044118_5271389622917272_422760944997931755_nlow.jpg">https://qcurban.commons.gc.cuny.edu/files/sb-instagram-feed-images/277044118_5271389622917272_422760944997931755_nlow.jpg</a></p>
<p>This format requires WordPress to load and check whether the file should be read-protected. In the case of the fully-public qcurban.org, this is never the case. Image URLs should be of the format:<br /><a class="external" href="https://qcurban.commons.gc.cuny.edu/wp-content/blogs.dir/20623/files/sb-instagram-feed-images/277044118_5271389622917272_422760944997931755_nlow.jpg">https://qcurban.commons.gc.cuny.edu/wp-content/blogs.dir/20623/files/sb-instagram-feed-images/277044118_5271389622917272_422760944997931755_nlow.jpg</a></p>
<p>Note the <code>/wp-content/blogs.dir/20623/</code> section in the middle.</p>
<p>I'm unsure at a glance why this is happening. I tested creating a new post on qcurban.org, and inserting an item from the Media Library. In the Media Library and in the Editor, images are loaded from the /wp-content/ URL. But when I view a preview on the front end, they've been changed to the /files/ format. I'll research this - and maybe Ray (CCed here) has some idea why it's happening - but in the meantime, you could go through saved pages, such as 'Front', and change the URL format for images (edit each image block as HTML).</p>
<p>Aside from the image issue, the TTFB is also extremely slow for the site. I enabled Query Monitor but it doesn't show anything egregious at the database level. I'll do some more diagnostics to see if I can narrow things down.</p> CUNY Academic Commons - Support #15767: Site loading slowlyhttps://redmine.gc.cuny.edu/issues/15767?journal_id=690112022-03-30T19:58:26ZBoone Gorgesboone@gorg.es
<ul></ul><p>It appears that ml-slider is adding 4 or 5 seconds to each page load. Here's the technical explanation: <a class="external" href="https://wordpress.org/support/topic/call-to-get_plugins-causing-performance-problems/">https://wordpress.org/support/topic/call-to-get_plugins-causing-performance-problems/</a> It's not obvious that I can work around this problem in ml-slider without forking the plugin.</p> CUNY Academic Commons - Support #15767: Site loading slowlyhttps://redmine.gc.cuny.edu/issues/15767?journal_id=690172022-03-30T20:28:05ZBoone Gorgesboone@gorg.es
<ul></ul><p>I have to step away for the day, but first to leave a note for myself and Ray: The blogs.dir problem appears to come from Mercator and domain mapping. When WP builds attachment URLs <code>wp_get_attachment_url()</code>, it uses <code>wp_upload_dir()</code>. The latter function uses <code>get_option( 'siteurl' )</code> to build its base values. In the case of a mapped domain, <code>get_option( 'siteurl' )</code> returns the <strong>unmapped</strong> value - Mercator only filters the <code>site_url()</code> wrapper function. As such, the various <code>str_replace</code> juggling in <code>wp_upload_dir()</code> doesn't work right.</p>
<p>I haven't fully worked out the details or though of a good workaround - maybe there's an additional filter we can apply in our own wp-content/mu-plugins/assets/mercator? - but I won't be able to look further today. Ray, if you have the interest and energy, as our local Mercator expert, I'd welcome your eyes. Otherwise I'll have another look in the upcoming days.</p> CUNY Academic Commons - Support #15767: Site loading slowlyhttps://redmine.gc.cuny.edu/issues/15767?journal_id=690202022-03-30T21:03:20Zscott vothscott.voth@verizon.net
<ul></ul><p>Thanks for all you help. I guess first step is to use a different slider plugin.</p> CUNY Academic Commons - Support #15767: Site loading slowlyhttps://redmine.gc.cuny.edu/issues/15767?journal_id=690222022-03-30T23:13:30ZRaymond Hoh
<ul></ul><blockquote>
<p>Aside from the image issue, the TTFB is also extremely slow for the site.</p>
</blockquote>
<p>This is the main issue.</p>
<blockquote>
<p>I guess first step is to use a different slider plugin.</p>
</blockquote>
<p>Yes, this is my main conclusion as well.</p>
<p>Deactivating MetaSlider speeds up the site by between 4-6 seconds per WordPress asset request (the main document, plus any asset requests to <code>/files/</code>). Deactivating other plugins can reduce the TTFB down to under a second.</p>
<p>I've left MetaSlider deactivated for now.</p>
<blockquote>
<p>When WP builds attachment URLs wp_get_attachment_url(), it uses wp_upload_dir(). The latter function uses get_option( 'siteurl' ) to build its base values. In the case of a mapped domain, get_option( 'siteurl' ) returns the unmapped value - Mercator only filters the site_url() wrapper function.</p>
</blockquote>
<p>Boone, thanks for your analysis here. I changed Mercator to filter <code>'option_home'</code> and <code>'option_siteurl'</code> instead of <code>'site_url'</code> and <code>'home_url'</code> on production (haven't committed the change to <code>wp-content/mu-assets/mercator/</code> yet), but that didn't really do much for the TTFB or asset load time.</p>
<p>Should all attachment URLs for public sites be written as <code>/wp-content/blogs.dir/</code> instead of <code>/files/</code>? If so, we can look at writing a filter to do this.</p> CUNY Academic Commons - Support #15767: Site loading slowlyhttps://redmine.gc.cuny.edu/issues/15767?journal_id=690232022-03-30T23:59:05ZBoone Gorgesboone@gorg.es
<ul></ul><p>Thanks, Ray!</p>
<blockquote>
<p>Boone, thanks for your analysis here. I changed Mercator to filter 'option_home' and 'option_siteurl' instead of 'site_url' and 'home_url' on production (haven't committed the change to wp-content/mu-assets/mercator/ yet), but that didn't really do much for the TTFB or asset load time.</p>
</blockquote>
<p>With Meta Slider deactivated, the home page doesn't call <code>wp_get_attachment_url()</code> very much. Instead, the URLs are saved in the post content. But to get a sense of load time differences, try these two URLs side by side (uncached especially):</p>
<p>a. <a class="external" href="https://qcurban.org/files/2022/03/wonderlane-mVnI4UxYxJI-unsplash2.jpg">https://qcurban.org/files/2022/03/wonderlane-mVnI4UxYxJI-unsplash2.jpg</a><br />b. <a class="external" href="https://qcurban.org/wp-content/blogs.dir/20623/files/2022/03/wonderlane-mVnI4UxYxJI-unsplash2.jpg">https://qcurban.org/wp-content/blogs.dir/20623/files/2022/03/wonderlane-mVnI4UxYxJI-unsplash2.jpg</a></p>
<p>The instances that are in the existing post content would have to be swapped out manually. But your filter fix should ensure that, for <strong>new</strong> content, the URLs inserted into <code>post_content</code> ought to have the longer URL.</p>
<blockquote>
<p>Should all attachment URLs for public sites be written as /wp-content/blogs.dir/ instead of /files/? If so, we can look at writing a filter to do this.</p>
</blockquote>
<p>I think the question is whether we should (a) go with the broader fix that you've currently done to Mercator (filtering option_home and option_siteurl), (b) filter <code>upload_dir</code> to make the necessary changes, or (c) specifically target the attachment URLs with a filter. Option (a) is the most general but has the greatest likelihood of side effects (though I can't think of any off the top of my head). Option (b) feels like it's the right level for the Mercator filter, but it's not totally straightforward because of the filter placement in WP - I think we'd need to reproduce some of the logic of <code>_wp_upload_dir()</code> to build the paths properly. With (c) we could pretty much just add Mercator's existing filters. What do you think?</p> CUNY Academic Commons - Support #15767: Site loading slowlyhttps://redmine.gc.cuny.edu/issues/15767?journal_id=691322022-04-04T19:26:43ZRaymond Hoh
<ul></ul><blockquote>
<p>I think the question is whether we should (a) go with the broader fix that you've currently done to Mercator (filtering option_home and option_siteurl)</p>
</blockquote>
<blockquote>
<p>Option (a) is the most general but has the greatest likelihood of side effects (though I can't think of any off the top of my head).</p>
</blockquote>
<p>There might have been a reason why Mercator did not filter <code>option_home</code> and <code>option_siteurl</code> in the first place.</p>
<p>While I think it makes sense to filter <code>option_home</code> and <code>option_siteurl</code> in theory, one side effect is since the attachment URLs would now point to the mapped domain and be saved in the post content, if a site ever decides to remove their domain mapping, then those attachment URLs would no longer work on the Commons subdomain site.</p>
<hr />
<blockquote>
<p>or (c) specifically target the attachment URLs with a filter</p>
</blockquote>
<p>This sounds the safest, but it's also a pain.</p>
<p>I was looking at some prior code I've written for another site and I had to use a bunch of filters -- <code>'the_post'</code>, <code>'the_content'</code>, <code>'the_excerpt'</code>, <code>'wp_get_attachment_image_src'</code>, <code>'wp_get_attachment_url'</code>, <code>'wp_calculate_image_srcset'</code>, <code>'theme_mod_header_image'</code>, <code>'theme_mod_background_image'</code>. Code was to replace attachment URLs with those uploaded to Amazon S3, but general approach would be the same here.</p>
<p>Do a regex search for any <code>/files/</code> URLs and switch them out for the <code>/blogs.dir/</code> equivalent if that site is public only. I think there is definitely some benefit to doing this.</p> CUNY Academic Commons - Support #15767: Site loading slowlyhttps://redmine.gc.cuny.edu/issues/15767?journal_id=691362022-04-04T21:56:10ZRaymond Hoh
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-5 priority-5 priority-high4 closed" href="/issues/15810">Bug #15810</a>: News Literacy Matters site loading over and over using Chrome</i> added</li></ul> CUNY Academic Commons - Support #15767: Site loading slowlyhttps://redmine.gc.cuny.edu/issues/15767?journal_id=691392022-04-04T21:58:28ZRaymond Hoh
<ul></ul><p>The <code>option_home</code> and <code>option_siteurl</code> filter change affected mapped domain single sign-on (see <a class="issue tracker-1 status-5 priority-5 priority-high4 closed" title="Bug: News Literacy Matters site loading over and over using Chrome (Resolved)" href="https://redmine.gc.cuny.edu/issues/15810">#15810</a>). It was causing a redirect loop. I've just removed the change on production.</p>
<p>Looks like filtering the attachment URLs is the way to go.</p> CUNY Academic Commons - Support #15767: Site loading slowlyhttps://redmine.gc.cuny.edu/issues/15767?journal_id=691442022-04-05T00:56:16ZBoone Gorgesboone@gorg.es
<ul></ul><p>Eesh, thanks for the quick response, Ray.</p>
<blockquote>
<p>'wp_get_attachment_image_src', 'wp_get_attachment_url', 'wp_calculate_image_srcset', 'theme_mod_header_image', 'theme_mod_background_image'</p>
</blockquote>
<p>Definitely we should do these. It's possible that 'wp_get_attachment_url' will do most of the work.</p>
<blockquote>
<p>'the_post', 'the_content', 'the_excerpt'</p>
</blockquote>
<p>These sorts of filters make me more nervous. We'd need to make sure we only look inside of 'src' attributes, not elsewhere in body text, but in any case we need to be very careful when running regular expressions on user-provided text. In fact, my inclination is to ignore post content. The 'wp_get_attachment_url' filter will ensure that <strong>future</strong> images inserted into posts will be correct. In some cases, like Scott's, it may be beneficial to go back and do the swapouts, but it should be done manually by the admin.</p> CUNY Academic Commons - Support #15767: Site loading slowlyhttps://redmine.gc.cuny.edu/issues/15767?journal_id=717742022-07-12T04:11:33ZRaymond Hoh
<ul></ul><p>Boone, while debugging <a class="issue tracker-3 status-11 priority-4 priority-default closed" title="Support: Events Calendar plugin problem (Abandoned)" href="https://redmine.gc.cuny.edu/issues/16346">#16346</a>, I found that the ACERT site was extremely slow and noticed that ml-slider did not apply <a href="https://wordpress.org/support/topic/call-to-get_plugins-causing-performance-problems/" class="external">your suggested fix</a> to the plugin. So I've <a href="https://github.com/cuny-academic-commons/cac/commit/680824c1181888814ebdd49bfb9edbff926a3a77" class="external">reapplied your hotfix</a> for ml-slider again: <a class="external" href="https://github.com/cuny-academic-commons/cac/commit/bb69429fc4a13cbecb4ab44c9fe3374b79d697da">https://github.com/cuny-academic-commons/cac/commit/bb69429fc4a13cbecb4ab44c9fe3374b79d697da</a></p> CUNY Academic Commons - Support #15767: Site loading slowlyhttps://redmine.gc.cuny.edu/issues/15767?journal_id=728892022-08-25T20:25:01ZRaymond Hoh
<ul><li><strong>Related to</strong> <i><a class="issue tracker-3 status-5 priority-4 priority-default closed" href="/issues/16659">Support #16659</a>: ILETC site loading time</i> added</li></ul> CUNY Academic Commons - Support #15767: Site loading slowlyhttps://redmine.gc.cuny.edu/issues/15767?journal_id=728932022-08-25T20:43:33ZRaymond Hoh
<ul></ul><p>Boone, while debugging <a class="issue tracker-3 status-5 priority-4 priority-default closed" title="Support: ILETC site loading time (Resolved)" href="https://redmine.gc.cuny.edu/issues/16659">#16659</a>, I found that the ILETC site was using <code>ml-slider</code> and again noticed that <code>ml-slider</code> did not apply your suggested fix from before. So I've reapplied your hotfix for ml-slider once more: <a class="external" href="https://github.com/cuny-academic-commons/cac/commit/8fb42bfa205a106702807d26bfd5cd8c0ae66323">https://github.com/cuny-academic-commons/cac/commit/8fb42bfa205a106702807d26bfd5cd8c0ae66323</a></p>
<p>I've replied on the wordpress.org forum thread that you created to hopefully make them aware of the problem: <a class="external" href="https://wordpress.org/support/topic/call-to-get_plugins-causing-performance-problems/">https://wordpress.org/support/topic/call-to-get_plugins-causing-performance-problems/</a></p> CUNY Academic Commons - Support #15767: Site loading slowlyhttps://redmine.gc.cuny.edu/issues/15767?journal_id=728982022-08-25T21:25:46ZBoone Gorgesboone@gorg.es
<ul></ul><p>Thanks for updating the thread, Ray - I was pleased to see they responded right away. I'll try to remember to look the next time ml-slider is updated.</p> CUNY Academic Commons - Support #15767: Site loading slowlyhttps://redmine.gc.cuny.edu/issues/15767?journal_id=728992022-08-25T22:08:55Zscott vothscott.voth@verizon.net
<ul></ul><p>I also had questions about the ml-slider on another issue, but I looked at the their update log and it looked like took Boone advice and fixed the issue.</p> CUNY Academic Commons - Support #15767: Site loading slowlyhttps://redmine.gc.cuny.edu/issues/15767?journal_id=763962023-01-24T00:38:38ZRaymond Hoh
<ul></ul><p>Boone, while looking into the ILETC site again, I noticed that the MetaSlider team has not addressed the <code>get_plugins()</code> issue from before. So I've re-applied <a href="https://github.com/cuny-academic-commons/cac/commit/8f0c3c5db8e11545cad6010a82cac5e690bbeccf" class="external">the hotfix from before</a> and have replied to the wordpress.org thread once more: <a class="external" href="https://wordpress.org/support/topic/call-to-get_plugins-causing-performance-problems/">https://wordpress.org/support/topic/call-to-get_plugins-causing-performance-problems/</a>. Hopefully they will address this issue soon.</p> CUNY Academic Commons - Support #15767: Site loading slowlyhttps://redmine.gc.cuny.edu/issues/15767?journal_id=785582023-04-12T16:58:11ZBoone Gorgesboone@gorg.es
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-7 priority-4 priority-default" href="/issues/18016">Bug #18016</a>: ml-slider get_plugins() call causes performance issues</i> added</li></ul> CUNY Academic Commons - Support #15767: Site loading slowlyhttps://redmine.gc.cuny.edu/issues/15767?journal_id=785602023-04-12T17:00:08ZBoone Gorgesboone@gorg.es
<ul><li><strong>Target version</strong> set to <i>2.2.0</i></li></ul><p>I just looked at the 3.29.1 release of ml-slider, which is scheduled to be deployed here on the Commons later in the month, and they team still hasn't fixed the problem. I've opened <a class="issue tracker-1 status-7 priority-4 priority-default" title="Bug: ml-slider get_plugins() call causes performance issues (Hold)" href="https://redmine.gc.cuny.edu/issues/18016">#18016</a> to address this.</p>
<p>We'll use the current ticket to continue discussion about whether we should be filtering image URLs on mapped-domain blogs. I think we can go with a fairly conservative approach for the next major release.</p> CUNY Academic Commons - Support #15767: Site loading slowlyhttps://redmine.gc.cuny.edu/issues/15767?journal_id=820812023-09-13T15:07:56ZBoone Gorgesboone@gorg.es
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-5 priority-4 priority-default closed" href="/issues/18204">Bug #18204</a>: 3d Flipbook Lite</i> added</li></ul> CUNY Academic Commons - Support #15767: Site loading slowlyhttps://redmine.gc.cuny.edu/issues/15767?journal_id=820832023-09-13T15:09:13ZBoone Gorgesboone@gorg.es
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>Resolved</i></li></ul><p>The mapped attachment issue came up again in <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: 3d Flipbook Lite (Resolved)" href="https://redmine.gc.cuny.edu/issues/18204">#18204</a>, so I've put in place a conservative version of the proposed filter. See <a class="external" href="https://github.com/cuny-academic-commons/cac/commit/abeb832bbafb6b8ef88c5da9aac3355ebfe3d323">https://github.com/cuny-academic-commons/cac/commit/abeb832bbafb6b8ef88c5da9aac3355ebfe3d323</a>. Let's run with this for a while and see if issues come up.</p>
<p>I'm continuing to monitor upstream changes in ml-slider in <a class="issue tracker-1 status-7 priority-4 priority-default" title="Bug: ml-slider get_plugins() call causes performance issues (Hold)" href="https://redmine.gc.cuny.edu/issues/18016">#18016</a>, so I'll mark the current ticket resolved.</p>