WordPress.org

Ready to get started?Download WordPress

Forums

fragment caching for PixoPoint Multi-level menu (20 posts)

  1. dpdoug
    Member
    Posted 2 years ago #

    I have discovered, through a process of elimination that it is my menu that slows down my blog. I use a PixoPoint Multi-level plugin for the menu. The menu is pretty big and it is loaded with every page. With the menu it takes approx 23 seconds to load a page, if I disable the menu a page load is under 5 seconds.

    I would like to cache nothing but the menu and only load it the first time the app is loaded so that subsequent page loads do not have to load it again, it is just added from the cache locally.

    I know that partial-page caching is done in asp.net, but that is done by using user controls.

    Does anyone know how to do this? I've read that it is called "fragment caching" in PHP.

    Doug

  2. Ryan Hellyer
    Member
    Posted 2 years ago #

    Hi,
    Sorry about that. I'm the developer of the plugin. I rewrote the plugin from scratch recently to solve those performance problems, but I haven't heard any reports from anyone who has used it so it hasn't been pushed live onto the repository yet.
    http://pixopoint.com/2012/04/05/multi-level-navigation-plugin-update/

    I would really appreciate it if you could try it to see if it solves your performance problems.

    Thanks :)

  3. Ryan Hellyer
    Member
    Posted 2 years ago #

    Oh, and if you really want to crank up performance, you should use the WordPress transient API to cache the menu contents, and turn off the plugins built in CSS file and move the CSS to your theme (or use a plugin which can dynamically concatenate your CSS files such as W3 Total Cache).

    That does require some technical know how to implement though.

  4. dpdoug
    Member
    Posted 2 years ago #

    I installed the new plugin and tried it out and after the first load (15 sec) each page loads in 3 seconds -- I am extremely happy with the new menu!

    There is one thing that I would like to change though. I have to make a copy of each post and create a page just for the purpose creating the menu. I have a page, without post text, just for the purpose of having a top level menu item. Then I use the pages with the texts as children of the top level menu.

    I would rather do the same for posts. That way I wouldn't have to update the pages every time I change something in a post and I wouldn't have to create duplicate pages for each post. Is there some way that I could implement this?

    If I use categories for the top level menu items, the posts in each category don't appear as child menu items. I'd like to be able to use posts the same way I use pages.

    Probably the only way to go is use pages instead of posts, but then I wouldn't have the recent posts to show.

    I'd like to have my cake and eat it too...

  5. dpdoug
    Member
    Posted 2 years ago #

    I've tried creating a custom menu going by the example, but when I save it the code in the "Custom Code" text box goes away and the menu is not displayed. Evidently this is a glitch.

    I thought maybe this could be a way to display my posts in the menu and not have to create (duplicate) pages just for the sake of having a menu.

    Alas... it doesn't work. :-(

  6. Ryan Hellyer
    Member
    Posted 2 years ago #

    I'll see what I can do about that glitch. Thanks for letting me know about it, I really appreciate the feedback :)

    It sounds like the functionality you want could be achieved most easily by uninstalling the plugin and using the built-in system for menus in WordPress. I built the plugin a long time before menus were implemented in core and for most people the built-in system is far more useful.

  7. dpdoug
    Member
    Posted 2 years ago #

    Is it just as fast?

  8. Ryan Hellyer
    Member
    Posted 2 years ago #

    It uses far more database queries. There are ways to cache the menu output, but it would require some PHP knowledge to figure out how to do the caching of them.

    Other than the number of queries it should be roughly the same speed as my plugin though.

  9. Ryan Hellyer
    Member
    Posted 2 years ago #

    I supposed I could take this opportunity to write up a "how to" guide on caching WordPress menu outputs I guess. Lots of people SHOULD be caching their menus, but almost nobody does.

  10. dpdoug
    Member
    Posted 2 years ago #

    I think that creating the code for the menu might not only run faster, but just about as easy as I know HTML very well.

  11. Ryan Hellyer
    Member
    Posted 2 years ago #

    Writing raw HTML will always be faster. Although at that point you may as well dump the code straight into your theme rather than using a plugin.

  12. Ryan Hellyer
    Member
    Posted 2 years ago #

    I found a tutorial here on caching WordPress menu outputs ... http://hitchhackerguide.com/2011/10/07/caching-wordpress-navigation-menus-wp_nav_menu-wrapper/

    That tutorial is a little overly verbose in my opinion as you can do the caching with a lot less code than that, but it does make sense and should work just fine.

  13. dpdoug
    Member
    Posted 2 years ago #

    I've read some on caching, but PHP is not my forte. I'm a .net programmer. A "how to" guide on caching WordPress menu outputs would be extremely useful to me. Some of those tutorials are written assuming that the reader is a seasoned programmer in PHP, so it's difficult to know how to use the code.

    I understand there is database caching and memory caching. I think I'd be more interested in memory caching since it is much faster.

  14. Ryan Hellyer
    Member
    Posted 2 years ago #

    This looks a little simpler :)
    http://www.dev4press.com/2011/tutorials/wordpress/practical/improve-your-wordpress-website-speed-part-2/

    This same method of caching can be used for many parts of your site, including widget areas etc. It's a really handy technique for situations in which you can't use a static file caching plugin like W3 Total Cache or WP Super Cache.

  15. dpdoug
    Member
    Posted 2 years ago #

    How would I go about "dumping the code straight into my theme"? Where would I put the code? If I did this would I still be able to cache it?

  16. dpdoug
    Member
    Posted 2 years ago #

    I've tried WP Super Cache, and I don't like the fact that I just makes copies of the whole page. So it just serves up a static page from the server instead of actually caching fragments of the page on the client side.

  17. Ryan Hellyer
    Member
    Posted 2 years ago #

    How would I go about "dumping the code straight into my theme"? Where would I put the code? If I did this would I still be able to cache it?

    I'm not sure how to answer that sorry. You would copy it to whichever part of the the required the menu code.

    I've tried WP Super Cache, and I don't like the fact that I just makes copies of the whole page. So it just serves up a static page from the server instead of actually caching fragments of the page on the client side.

    You can't cache bits of the page on the client side, so not sure what you mean there.

    I'm working on the plugin right now. I'm not sure what is causing the bug you experienced, but I'll see if I can it fixed soon.

  18. Ryan Hellyer
    Member
    Posted 2 years ago #

    Plugin has now been upgraded in the official repo. ... http://wordpress.org/extend/plugins/multi-level-navigation-plugin/

    The bug you mentioned has been ironed out and all of the performance enhancements are now available in that version too.

  19. dpdoug
    Member
    Posted 2 years ago #

    I tried to put an html menu in the header.php file but I ended up getting an error:

    Parse error: syntax error, unexpected '}'

    I uploaded the backup I'd made and I still kept getting the error. So I re-installed the theme and it's working again now, but I can't get the PixoPoint Multi-level menu to display anymore. I even installed the latest version and that didn't help either.

    What should I do to get the menu working again? All the settings are exactly the same as they were before.

  20. Ryan Hellyer
    Member
    Posted 2 years ago #

    I don't think there's anything I can do to help there sorry. It sounds like you changed something as the menu shouldn't just disappear like that.

Topic Closed

This topic has been closed to new replies.

About this Topic