• Resolved jtcheng

    (@jtcheng)


    Hi,

    I’ve been liberally using this plugin because of its simplicity and flexibility.

    However, as my database has grown (and will continue to grow with new posts), I’ve noticed that display-posts-shortcode has been slowing down page loads.

    For example, the page I’ve put in the referral link as the “page you need help with” currently averages around 6-9 seconds of page load, and it’s mostly the display posts shortcode now.

    Is it possible to display the results by AJAX loading (possibly as a premium option or extension)? This is something I would be willing to pay for to continue using this plugin in a production level environment.

    Thanks

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Bill Erickson

    (@billerickson)

    I’m sorry to hear you’re having performance issues. Can you share the specific shortcodes you’re using on that page so I can see the types of queries you’re doing?

    I highly recommend you add some form of page caching to your site. RocketWP is my favorite (it’s a paid plugin), but there are quite a few free ones as well, like W3 Total Cache. These will save a copy of your page as static HTML and serve that up to visitors rather than regenerating the page on every request.

    That doesn’t solve your core performance issue though. Uncached hits will still load slow.

    To solve your performance issue, I recommend you dig a little deeper. Install Query Monitor to see a list of all the queries running on that page and which are affecting the pageload the most.

    My guess is either:

    a) It’s not directly caused by Display Posts Shortcode; or
    b) You’re running incredibly complex query on a massive database

    Once I know more about the query I can provide better guidance.

    You gave me an idea for a potential addon plugin – the ability to cache DPS queries as a transient. You could say [display-posts transient_key=”my_cached_query” transient_expiration=”DAY_IN_SECONDS”] which would cache the results and update it once a day.

    I’m not sure there’s really a need for this – page caching should take care of it for you – but if you do have a computationally expensive query that can be updated infrequently, it might be a fun use case for that.

    Thread Starter jtcheng

    (@jtcheng)

    Hi,

    Thanks for getting back to me on this.

    I can definitely say that b) is the scenario that’s going on because I’ve noticed page load times increase as I put in more new posts (i.e. grow the database therefore increase the query complexity).

    Because I have a membership site (i.e. logged in users get to contribute content or comment to cut down on spam), that this is where the page caching doesn’t work.

    Unfortunately, logged in members also happen to be the most loyal of the website audience so to make them wait to load pages would not be good.

    In any case, here are a couple of examples of how I use display posts shortcode.

    Direct shortcode as text block on particular pages using Visual Composer:
    [display-posts post_type=”page” category=”country” wrapper=”div” wrapper_class=”class-c” orderby=”title” order=”ASC” posts_per_page=”-1″]

    Appying PHP in a template like so:
    do_shortcode(‘[display-posts post_type=”userwaterfallreview” category=”user-replies” meta_key=”wp_parent_post_id” meta_value=”‘ . $postID . ‘” no_posts_message=”No users have replied to the content on this page” posts_per_page=”-1″ orderby=”date” order=”DESC” image_size=”medium” wrapper=”div” include_author=”true” include_date=”true” date_format=”F j, Y g:i a” include_excerpt=”true” excerpt_length=”55″ excerpt_more=”…Read More” excerpt_more_link=”true”]’);

    Plugin Author Bill Erickson

    (@billerickson)

    Can you provide a screenshot of the Query Monitor on a page that’s slow?

    Thread Starter jtcheng

    (@jtcheng)

    Hi,

    Here’s a link to the screenshot.

    https://snag.gy/BhU3DI.jpg

    This North America page seems to be consistently bad (clocking in at around 45 seconds or so when I’m logged in).

    This page uses display posts shortcode multiple times.

    Thanks

    Plugin Author Bill Erickson

    (@billerickson)

    You have 1,635 queries running on that page, which is REALLY high.

    Go into the “Queries” and “Queries by Caller” tabs for more information. Also look for “Queries by Component” which is what I really was looking for but don’t see in your screenshot. That shows you which components of your site are responsible for the queries (WP core, theme, and individual plugins).

    Here’s a screenshot ( https://cl.ly/9b461baf1461 ) from a site I’m working on now. I added [display-posts post_type="page"] to a page and it added 2 queries.

    Thread Starter jtcheng

    (@jtcheng)

    I managed to limit one of the display posts shortcode queries to set posts_per_page=”16″ posts (for user submitted reviews). It was previous “-1”.

    That brought the query count down to 337 according to this screenshot (which has your Queries by Caller tab shown):
    https://snag.gy/HfOd9Q.jpg

    But that should indicate to you that most of the queries are coming from display posts shortcode.

    It’s querying through a large database, which is why I’m wondering if transient caching would help alleviate server load (though it seems like some services like Kinsta have their own page caching and it seems to perform admirably even if I’m logged in).

    I currently had a developer modify display-posts-shortcode to output the results with AJAX so at least the user could navigate the post or page without the page load being held hostage.

    Not sure if we’re going about this the right way though to improve user experience.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Suggestion: AJAX load results to speed up page load’ is closed to new replies.