tires Posted Wednesday at 10:43 AM Share Posted Wednesday at 10:43 AM I have a site with about 5000 subpages and have noticed that it now takes about 10 seconds to save a page. What could be the reason for this and how can I speed up the site? Link to comment Share on other sites More sharing options...
AndZyk Posted Wednesday at 10:58 AM Share Posted Wednesday at 10:58 AM Hello @tires, have you tried looking in TracyDebugger if there is an error? Do you use hooks or special modules? The amount of subpages should not be an issue in my experience. Maybe there is something else going on. Regards, Andreas 1 Link to comment Share on other sites More sharing options...
tires Posted Wednesday at 11:54 AM Author Share Posted Wednesday at 11:54 AM Thank you very much for your advice! I have indeed found a hook that was apparently to blame. I can't remember exactly why I added it and what it does ... $wire->addHookAfter('Pages::saveReady', function($event) { $event->modules->get('SearchEngine')->indexPages(); $page = $event->arguments(0); $event->wire('log')->save('Page saved', "Page ID: $page->id / Page Name: $page->name / Page Parents: $page->parents"); }); 3 Link to comment Share on other sites More sharing options...
da² Posted Wednesday at 02:01 PM Share Posted Wednesday at 02:01 PM 2 hours ago, tires said: $event->modules->get('SearchEngine')->indexPages(); You are indexing all the site pages every time a page is saved. You should index only this page since the work for other ones was already done. 3 Link to comment Share on other sites More sharing options...
AndZyk Posted Wednesday at 02:10 PM Share Posted Wednesday at 02:10 PM Happy to hear you found the issue. 😀 You could consider indexing the pages with a Lazy Cron or a cronjob. 2 Link to comment Share on other sites More sharing options...
da² Posted Wednesday at 03:23 PM Share Posted Wednesday at 03:23 PM Solution is here: https://processwire.com/modules/search-engine/ // Alternatively index just a single page (passing in a Page object): $modules->get('SearchEngine')->indexPage($page); 3 Link to comment Share on other sites More sharing options...
tires Posted Thursday at 07:13 PM Author Share Posted Thursday at 07:13 PM On 12/18/2024 at 4:23 PM, da² said: Solution is here: https://processwire.com/modules/search-engine/ // Alternatively index just a single page (passing in a Page object): $modules->get('SearchEngine')->indexPage($page); I can't really remember why I used this module (it's been a few years). Do I really need it to find the content of the pages? You mean I should simply adapt the ready.php to, right? $wire->addHookAfter('Pages::saveReady', function($event) { $event->modules->get('SearchEngine')->indexPages($page); $page = $event->arguments(0); $event->wire('log')->save('Page saved', "Page ID: $page->id / Page Name: $page->name / Page Parents: $page->parents"); }); Thank a lot! Link to comment Share on other sites More sharing options...
da² Posted Friday at 02:02 AM Share Posted Friday at 02:02 AM (edited) 6 hours ago, tires said: Do I really need it to find the content of the pages? If you have a search page that allows to search text in a lot of pages containing big texts, you probably need it. Do a performance benchmark with and without. 6 hours ago, tires said: You mean I should simply adapt the ready.php to, right? Yes but without the mistake you did on the method name. 😁 Edited Friday at 02:03 AM by da² 1 Link to comment Share on other sites More sharing options...
tires Posted Saturday at 05:31 PM Author Share Posted Saturday at 05:31 PM On 12/20/2024 at 3:02 AM, da² said: Yes but without the mistake you did on the method name. 😁 Which mistake do you mean? 🤓 By the way, do I need this hook at all or does the module automatically index the edited page when it is saved? Link to comment Share on other sites More sharing options...
da² Posted Saturday at 05:34 PM Share Posted Saturday at 05:34 PM 1 minute ago, tires said: Which mistake do you mean? 🤓 I won't help for reading a function name. 😆 2 minutes ago, tires said: By the way, do I need this hook at all or does the module automatically index the edited page when it is saved? I don't know the module, check the documentation. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now