Closed Bug 747166 Opened 12 years ago Closed 12 years ago

kumascript: Optimize wiki.page

Categories

(developer.mozilla.org Graveyard :: Wiki pages, defect, P2)

x86
macOS
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: lorchard, Assigned: lorchard)

References

Details

(Whiteboard: u=contributor c=wiki s=2012-05-22 p=)

In building DekiScript API shims, I found wiki.page. This allows one page to include the content of another page, with macros evaluated and class="noinclude" blocks omitted.

As it happens, some pages use this liberally and that generates a lot of HTTP requests. en/XUL/textbox, for one, generates a few hundred requests to build that page from dozens of others.

Part of this can be addressed with bug 747151, by minimizing how many requests kumascript needs to make to kuma for auto-required libs and other templates.

bug 747160 might help too, if wiki.page can use memcache to cache some of its own results.
Blocks: 747145
Depends on: 747160, 747151
And here's a peek at the code from http://mdn.lmorchard.com/en-US/docs/en-US/Template:DekiScript:Wiki


    // Retrieve the content of a document for inclusion
    // TODO: NEED CACHING HERE, BADLY!
    page: function (path) {
        var p = kuma.url.parse(env.url, true);
        var base = p.protocol + '//' + p.host + '/en-US/docs/';           
        var doc_url = base + path + '?raw=1&macros=1&include=1';
        var opts = { method: 'GET', url: doc_url };
        var result = '';
 
        var f = new Future();
        request(opts, function (err, resp, body) {
            if (resp && 200 == resp.statusCode) { result = body; }
            f.return();
        });
        f.wait();
         
        return result;       
    },
Maybe part of this optimization is to set really long expiration times on cached results on the KumaScript side. Then, invalidate cache entries from the Kuma script side when pages are saved. This would assume a shared naming convention in the cache on both sides.
Whiteboard: u=contributor c=wiki s=2012-05-22
Merged: https://github.com/mozilla/kumascript/commit/736845b167278dbcf3c452bb2a320a255b5767e0
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Blocks: 710728
No longer blocks: 659364
Priority: -- → P2
Retroactively setting assignee to Les.
Assignee: nobody → lorchard
Whiteboard: u=contributor c=wiki s=2012-05-22 → u=contributor c=wiki s=2012-05-22 p=
Version: Kuma → unspecified
Component: Website → Landing pages
Product: developer.mozilla.org → developer.mozilla.org Graveyard
You need to log in before you can comment on or make changes to this bug.