동적 페이지는 이미 만들 수 있지만 제대로 작동하지만 방문 페이지가 매우 느리게로드됩니다.PHP로 동적으로 신속하게 페이지 생성
정말 도움이 필요합니다. 아래는 내 사이트의 기능입니다.
의이 http://example.com/search.php
에 대한 링크와 함께 시작하자 :
<?php
session_start();
//(pretend there is code here that gets, decodes, and displays data from an api)
$title = $titleFromApi;
$a = $dataFromApi;
$_SESSION['storeTitle'] = $title; // stores 'title' in a session variable
$_SESSION['store_a'] = $a; // stores 'a' in a session variable
echo '<a href="http://example.com/'. $a .'/' . $title .'> ' . $title . '</a>';
// the line above is a clickable link that will take them to the landing page
?>
을 지금 여기에 방문 페이지 (http://example.com/$a/$title
)입니다 : 난 그냥 오늘 세션에 대해 알게
<?php
session_start();
$al = $_SESSION['store_a']; // stores session variable in new variable 'al'
$getter = 'http://api.somewebsite.com/dev/' . $al . '/get_these_variables';
// the line above gets data from an api using variable 'al'
// (pretend that there is code here that decodes the data)
// the code below displays the data retrieved from the api
foreach($data as $entry){
echo '
<div>
' . $entry['decoded_data_1']
. '
</div>
<div>
' . $entry['decoded_data_2'] // and so on
. '
</div>
'; // ends echo
}
?>
가 (나는 빨리 일을 할 것이라고 생각); 이전에 search.php에서 검색 주소창으로 데이터를 보낸 다음 방문 페이지에서 변수를 읽으려고 읽었습니다. (필자는 PHP와 개발에 대해 처음 접했습니다.) 방문 페이지의 페이지로드 속도가 변경되지 않았습니다.
원격 사이트로 전화를 거는 중입니다. 이는 항상 원격 사이트가 응답하는 데 걸리는 시간만큼 페이지가 표시되는 것을 의미합니다. – GordonM
search.php 페이지가 mysite.com과 다른 도메인에 있습니까? –
코드에서 두 개 이상의 점 사이의 타이밍을 측정하려면'microtime (true) '을 사용하십시오. @Gordon이 말했듯이 병목 현상을 식별하는 데 도움이 될 것입니다. 아마도 API 호출 일 것입니다. 아마 API가 느리거나 느린 네트워크에 있습니까? – halfer