2014-10-30 90 views
0

我已经在Xampp上安装了prerender.io,我什么也没有看中。刚刚安装了prerender需要的所有内容,并按照prerender.iohttps://github.com/zf-fr/zfr-prerender的文档。 因此,可以说,我已经把预渲染在这里:phantomjs输出奇怪的字符

/public/assets/services/prerender 

并在控制台中我跑:

npm install 
node server.js 

ZFR-预渲染的是中间件和我只改一个啄,是指在网址到预渲染:

'prerender_url' => 'http://localhost:3000/public/assets/services/prerender', 

在我的浏览器,我去:

本地主机/店铺/ API /列表_escaped_fragment_ =

从angularJS路由器重定向到/列表/ 1当没有发现的路由:

ListerApp.config(['$routeProvider', '$httpProvider', '$locationProvider', function($routeProvider, $httpProvider, $locationProvider) { 
$locationProvider.html5Mode(true); 
$locationProvider.hashPrefix('!'); 
$routeProvider 
    .when('/list/:page?', 
     { 
      templateUrl : '/assets/services/partials/list.html', 
      controller : 'ListerCtrl', 
      reloadOnSearch : false, 
      js : ['/assets/min/shoplist_js.min.js', '/assets/min/bootstrap-typeahead.min.js'], 
      //css : [], 
      resolve : { 
       sharedServiceAppData: function($sharedData){ 
        // sharedFactoryAppData will also be injectable in your controller, if you don't want this you could create a new promise with the $q service 
        return $sharedData.promise(); 
        //return; 
       } 
      } 
     } 
    ) 
    .otherwise({ redirectTo: '/list/1' }); 

}]);

控制台告诉我:

getting public/assets/services/prerender/http://localhost/shop/api/list 
got 200 in 419ms for public/assets/services/prerender/http://localhost/shop/api/list 

但所有的phantomJS回报奇怪的字符。

public function prerenderPost(PrerenderEvent $event) 
{ 
    // This is the response we get from the Prerender service 
    $response = $event->getResponse(); 
    var_dump($response->getHeaders()); 
    var_dump($response->getContent()); 
    // You could get the body and put it in cache 
    // ... 

} 

这些都是集流管,后续代码var_dump($响应 - > getHeaders()):

array (size=5) 
    0 => 
    array (size=2) 
     'name' => string 'Content-Type' (length=12) 
     'line' => string 'Content-Type: text/html;charset=UTF-8' (length=37) 
    1 => 
    array (size=2) 
     'name' => string 'Content-Encoding' (length=16) 
     'line' => string 'Content-Encoding: gzip' (length=22) 
    2 => 
    array (size=2) 
     'name' => string 'Content-Length' (length=14) 
     'line' => string 'Content-Length: 45' (length=18) 
    3 => 
    array (size=2) 
     'name' => string 'Date' (length=4) 
     'line' => string 'Date: Thu, 30 Oct 2014 18:23:39 GMT' (length=35) 
    4 => 
    array (size=2) 
     'name' => string 'Connection' (length=10) 
     'line' => string 'Connection: close' 

这是一个PHP的var_dump($响应 - >的getContent()):

字符串“<³É(EI±³ÉHML±³Ñ‡PIU)•@” + 'H'”(长度= 45)

<³É(EI±³ÉHML±³Ñ ‡PIù)•@“+'H'

+1

这应该是一个详细的错误报告https://github.com/zf-fr/zfr-prerender/issues或https://github.com/prerender/prerender/issues – 2014-10-30 23:12:52

+1

是的,多一点关于你所做的事情(以及你访问的URL)的信息将会很有帮助。谢谢! – 2014-10-31 06:23:09

+0

谢谢,我会编辑这个问题,所以有更多的信息。我会在github上发布它。我们(或我)稍后可能会参考github讨论,以便人们可以在此找到关于此问题的更多信息。 – poashoas 2014-10-31 08:07:39

回答

0

首先,解压缩并获得你需要

$response->getBody() 

其次所有的内容,这可能是有用的,以增加去ZFR-prenderer模块插槽超时的情况下,你有一台非常非常老旧的电脑。