title: Wordpress url to html
body: <p>I'm trying to ajaxify wordpress the clean way. The idea is this: </p>
  
  <ol>
  <li>Ajax request is made from client to ajax action url (for example <code>/wp/wp-admin/admin-ajax.php?action=my_plugin_fetch_page&amp;page=http://example.com/about</code>).</li>
  <li>Response of that request should be in JSON format and contain at
  least page title and content of page (equivalent to
  <code>http://example.com/about</code>).</li>
  </ol>
  
  <p>I cannot figure out a good way to get contents of page by only knowing its url.</p>
  
  <p>I have tried using <code>wp_remote_get</code>. So I simply make another request from server to url <code>http://example.com/about</code>. This works, but it's quite slow (slowing down a request about 2 seconds).</p>
  
  <p>I have tried using <code>url_to_postid</code>, which converts url to <code>post_id</code>. Unfortunately this does not work for archive pages and probably would be useless anyways, since I need full response body from url <code>http://example.com/about</code>, not just id of the equivalent page.</p>
  
  <p>This is how it works currently with <code>wp_remote_get</code>:</p>
  
  <pre><code>function my_plugin_fetch_page () {
  
      /*
       *
       * Getting url of target page from GET parameters
       *
       */
      $url = $_GET['page'];
  
      $title = '';
      $content = '';
  
      /*
       *
       * Url must be set in request parameters and it must be internal link
       *
       */
      if ( $url &amp;&amp; my_plugin_is_internal_page( $url ) ) {
  
          /*
           *
           * Format relative urls to absolute urls.
           *
           * test/example -&gt; http://example.com/test/example
           *
           */
          $url = nolife_single_format_url( $url );
  
          /*
           *
           * Make GET request.
           *
           */
          $page_response = wp_remote_get( $url, array(
              'user-agent'  =&gt; 'InternalRequester'
          ) );
  
          if ( ! is_wp_error( $page_response ) ) {
  
              /*
               *
               * Response contains title and page content seperated by some
               * seperator. By splitting response from that seperator, we
               * get title and contents of page in seperate values.
               *
               */
              $content_parts = explode( MY_PLUGIN_SEPERATOR, wp_remote_retrieve_body( $page_response ) );
  
              // title comes first
              $title = $content_parts[0];
  
              // then content of page
              $content = $content_parts[1];
          }
      }
  
      wp_send_json( array(
          'url'      =&gt; $url,
          'title'    =&gt; $title,
          'content'  =&gt; $content
      ) );
  
      die;
  }
  </code></pre>
  
  <p>Can anyone please help me with this one?</p>