-1

私はオフライン Web アプリケーションを作成し、キャッシング方法に取り組んでいます...私は常に更新されている jquery を使用しているため、これらに Cookie を使用したいと考えています。

<link rel="apple-touch-icon" href="themes/images/apple-touch-icon.png"/>
<link rel="apple-touch-startup-image" href="themes/images/tstartup.png" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="mobile-web-app-status-bar-style" content="black" />
<meta name="apple-mobile-web-app-capable" content="yes" />

そのため、それらは IPhone にのみ送信されます... サーバー側の PHP がすべてを行う必要があります... 問題は、PHP ファイルがキャッシュされている場合、計算されないことです...それが私の質問です。サイトを事前に計算してから保存しますか?

Ps私の英語でごめんなさい

4

1 に答える 1

1

キャッシュされたファイルでも、php コードと変数を呼び出すことができます。これを「回避」する方法があります。正確にどのようにキャッシュするかはわかりませんが、PHP を使用すると次のようになります。

    <?php

    /*start caching*/
    ob_start();

    SOME PHP OR HTML CODE HERE

    /*this will store "already executed code" in cache and clears the buffer*/
    $storecodeincache .= ob_get_contents();
    ob_end_clean();

    /*now at this point there is a piece of code we want to execute later, so we
use the same variable, but we store store PHP code we want execute later like this:*/      

    $storecodeincache .= 'SOMEPHPCODE';

    /*we start regular caching again*/
    ob_start();

    SOME PHP OR HTML CODE HERE

    /*we are finished, we want to store the rest*/
    $storecodeincache .= ob_get_contents();
    ob_end_clean();

    /*not neccessary, just when you call the script you see what has been cached*/
    echo $storecodeincache ;

    /*write all cached content into the file*/
    $handle = fopen('safe://pathwhereyousavethecachedcontent', 'w'); 

    fwrite($handle, $storecodeincache ); 

    fclose($handle); 

    ?>

最も重要な部分は、$storecodeincache .= ob_get_contents();キャッシングを停止した最初の段階です。これにより、実行されていないPHP コードがキャッシュされたファイルに保存されます。この時点では、「キャッシュされていません」が、このコードはキャッシュされたファイルに保存されます。私たちがしたので

$storecodeincache .= ob_get_contents();
ob_end_clean();

キャッシングを終了しました。そして、私たちはやっています

ob_start();

その後(キャッシュが再び開始されます)。しかしその間、PHPキャッシュはオフになっています。このような任意の時点で PHP キャッシュをオフにし、実行されていないPHP コードを「既に実行されたコード」のキャッシュに使用される同じ変数に保存してから、次に進みます (キャッシュを再度オンにして続行します)。

于 2013-08-07T19:34:27.340 に答える