{"id":2951,"date":"2016-04-19T19:52:51","date_gmt":"2016-04-19T23:52:51","guid":{"rendered":"https:\/\/antipaucity.com\/?p=2951"},"modified":"2016-04-19T19:52:51","modified_gmt":"2016-04-19T23:52:51","slug":"helping-a-magpierss-powered-site-perform-better","status":"publish","type":"post","link":"https:\/\/merikebi.warrenmyers.com\/?p=2951","title":{"rendered":"helping a magpierss-powered site perform better"},"content":{"rendered":"<p>I rely on <a href=\"http:\/\/magpierss.sourceforge.net\/\">MagpieRSS<\/a> to run one of my <a href=\"http:\/\/datente.com\">websites<\/a>. (If you&#39;d like to see the basic code for the site, see my {{GitHub}} <a href=\"https:\/\/github.com\/volcimaster\/datente\">profile<\/a>.)<\/p>\n<p>One of the drawbacks to Magpie, and dynamic websites in general, is they can be bottlenecked by external sources &#8211; in the case of Magpie, those sources are the myriad {{RSS}} feeds that <a href=\"http:\/\/datente.com\">Datente<\/a> draws from.<\/p>\n<p>To overcome some of this sluggishness, and to take better advantage of the caching feature of Magpie, I recently started a simple <code>cron<\/code> job to load every page on the site every X minutes &#8211; this refreshes the cache, and helps ensure reader experience is more performant. By scheduling a background refresh of every page, I cut average page load times by nearly a factor of 10! While this is quite dramatic, my worst-performing page was <em>still<\/em> taking upwards of 10 seconds to load a not-insignificant percentage of the time (sometimes more than a minute!) \ud83d\ude41<\/p>\n<p>Enter last week&#39;s epiphany &#8211; since RSS content doesn&#39;t change all <em>that<\/em> often (even crazy-frequent-updating feeds rarely exceed 4 updates per hour), I could take advantage of a &quot;trick&quot;, and change the <em>displayed<\/em> pages to be nearly static (I still have an Amazon sidebar that&#39;s dynamically-loaded) &#8211; with this stupidly-simple hack, I cut the slowest page load time from ~10-12 seconds to &lt;1: or another 10x improvement!<\/p>\n<p>&quot;What is the &#39;trick&#39;,&quot; you ask? Simple &#8211; I copied every page and prefixed it with a short character sequence, and then modified my <code>cron<\/code> job to still run every X minutes, but <em>now<\/em> call the &quot;build&quot; pages, redirecting the response (which is a web page, of course) into the &quot;display&quot; pages. In other words, make the display pages <em>static<\/em> by building them in the background every so often.<\/p>\n<p>If you&#39;d like to see exactly how I&#39;m doing this for one page (the rest are similar), check out this stupidly-short shell script:<\/p>\n<pre><code>(time (\/bin\/curl -f http:\/\/datente.com\/genindex.php &gt; ~\/temp.out)) 2&gt;&amp;1 | grep real\n<\/code><\/pre>\n<p>(The <code>time<\/code> is in there for my <code>cron<\/code> reports.)<\/p>\n<p>Compare the run time to the [nearly] static version:<\/p>\n<pre><code>(time (\/bin\/curl -f http:\/\/datente.com\/index.php &gt; ~\/temp.out)) 2&gt;&amp;1 | grep real\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I rely on MagpieRSS to run one of my websites. (If you&#39;d like to see the basic code for the site, see my {{GitHub}} profile.) One of the drawbacks to Magpie, and dynamic websites in general, is they can be bottlenecked by external sources &#8211; in the case of Magpie, those sources are the myriad &hellip;<br \/><a href=\"https:\/\/merikebi.warrenmyers.com\/?p=2951\" class=\"more-link pen_button pen_element_default pen_icon_arrow_double\">Continue reading <span class=\"screen-reader-text\">helping a magpierss-powered site perform better<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[31,41],"tags":[237,450,562,644,842],"keyring_services":[],"class_list":["post-2951","post","type-post","status-publish","format-standard","hentry","category-personal","category-technical","tag-development","tag-linux","tag-php","tag-rss","tag-website"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/2951","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2951"}],"version-history":[{"count":0,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/2951\/revisions"}],"wp:attachment":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2951"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2951"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2951"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fkeyring_services&post=2951"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}