Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-68524

Add Template and string prefetching

XMLWordPrintable

    • MOODLE_39_STABLE
    • MOODLE_39_STABLE
    • MDL-68524-master
    • Hide

      This is a hard one to test as it requires a fairly in-depth knowledge and understanding of the way in which Moodle fetches and stores its strings and templates.

      Check that the initial prefetch occurs

      Since pre-fetching only has an noticeable effect if the resources are not already cached in the browser, it is only active when cachejs is enabled.

      1. Disable developer mode (cachejs in particular)
      2. Open Moodle to the login page
      3. Open developer tools
      4. Purge caches via CLI:

        php admin/cli/purge_caches.php
        

      5. In browser developer tools ensure that the "Network" tab is shown
      6. Clear the Network tab and force it to show only XHR requests
      7. Refresh the login page
        1. Confirm that a short while after the page loaded there were three new requests
      8. Look at each request and confirm that you see:
        1. core_load_template
        2. several strings being fetched in a single query
        3. core_output_load_fontawesome
      9. Clear the Network tab again
      10. Refresh the login page
        1. Confirm that you do not see these requests again
      11. Run the following in the "Console" tab of the browser tools

        require(['core/modal_factory'], F => { window.F = F; });
        

      12. Open the "Network" tab and clear the list of network requests
      13. Run the following in the browser console

        F.create({title: 'test', body: 'body', type: F.types.SAVE_CANCEL}).then(modal => modal.show());
        

        1. The modal should open immediately
          Note: if this is tested before MDL-68528 then you will see an extra query because of the lack of normalisation.

      If you compare this to master before this change, you will see about 8 queries and the modal is slower to open. I'd recommend slowing the connection from the Network tab of your browser to see this in a really pronounced fashion.

      1. CI should continue to pass
      Show
      This is a hard one to test as it requires a fairly in-depth knowledge and understanding of the way in which Moodle fetches and stores its strings and templates. Check that the initial prefetch occurs Since pre-fetching only has an noticeable effect if the resources are not already cached in the browser, it is only active when cachejs is enabled. Disable developer mode ( cachejs in particular) Open Moodle to the login page Open developer tools Purge caches via CLI: php admin/cli/purge_caches.php In browser developer tools ensure that the "Network" tab is shown Clear the Network tab and force it to show only XHR requests Refresh the login page Confirm that a short while after the page loaded there were three new requests Look at each request and confirm that you see: core_load_template several strings being fetched in a single query core_output_load_fontawesome Clear the Network tab again Refresh the login page Confirm that you do not see these requests again Run the following in the "Console" tab of the browser tools require(['core/modal_factory'], F => { window.F = F; }); Open the "Network" tab and clear the list of network requests Run the following in the browser console F.create({title: 'test', body: 'body', type: F.types.SAVE_CANCEL}).then(modal => modal.show()); The modal should open immediately Note: if this is tested before MDL-68528 then you will see an extra query because of the lack of normalisation. If you compare this to master before this change, you will see about 8 queries and the modal is slower to open. I'd recommend slowing the connection from the Network tab of your browser to see this in a really pronounced fashion. CI should continue to pass

      I've discovered that one of the things which makes initial interactions in Moodle significantly slower is that we often fetch templates in response to a user interaction.

      Depending on the page, we often know that certain interactions are highly likely, but we should prioritise fetching the page and page resources before we fetch any strings or templates.

            dobedobedoh Andrew Lyons
            dobedobedoh Andrew Lyons
            Simey Lameze Simey Lameze
            Jun Pataleta Jun Pataleta
            Jun Pataleta Jun Pataleta
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 5 minutes
                1d 5m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.