cache dynamic page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    cache dynamic page

    Hey guys,

    I've seem to forgotten how to cache a php page so that when the a link is clicked the dynamic content is only grabbed from the DB only once a day.

    every Google results point to /not/ caching.

    I've got caching enabled so that now my back/forward browser button do not regenerate the page.

    FYI: It's a report that takes a long time to regenerate.

    Other pages on my site, the search and filter pages, those should not cache anything, so whatever solution, it must apply to specific pages.


    Code:
    Code:
    $secondsToMidnight = (strtotime('midnight')+86400)-time();
    header("Pragma: public");
    header("Cache-Control: maxage=$secondsToMidnight"); // HTTP/1.1
    header("Expires: " . date('r',time()+$secondsToMidnight)); // Date in the past
    Besides saving the output buffer to a file, is there any other way to force PHP/FF Browser to keep the same output.

    Thanks,




    Dan
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    you mean something like Memcache?

    Comment

    • dlite922
      Recognized Expert Top Contributor
      • Dec 2007
      • 1586

      #3
      Yes, from the description of it, it looks like that's along the lines of what i'm looking for, but not a PECL installation. I'm working with php 5.1.6 core only.

      Thanks,


      Dan

      Comment

      • dlite922
        Recognized Expert Top Contributor
        • Dec 2007
        • 1586

        #4
        If anybody else is following this, here's what i'm looking into



        Cheers



        Dan

        Comment

        • Dormilich
          Recognized Expert Expert
          • Aug 2008
          • 8694

          #5
          AFAIK, there is no built-in caching in PHP, although APC might make it into PHP 6. (ref)

          have you thought about Prepared Statements?

          Comment

          • kovik
            Recognized Expert Top Contributor
            • Jun 2007
            • 1044

            #6
            Search engines perform particular searches once every so often, and then save the results into another database table for easy access. Maybe you'd be interested in that technique?

            Comment

            • Dormilich
              Recognized Expert Expert
              • Aug 2008
              • 8694

              #7
              that’s like session storage in a DB …

              Comment

              • Markus
                Recognized Expert Expert
                • Jun 2007
                • 6092

                #8
                You could just perform the cache yourself? Saving the content to a static .html file , checking on page load whether it needs to be updated.

                Comment

                • kovik
                  Recognized Expert Top Contributor
                  • Jun 2007
                  • 1044

                  #9
                  @Markus: I thought that's what the PHP cache apps did. I've never tried any, though.

                  Comment

                  • dlite922
                    Recognized Expert Top Contributor
                    • Dec 2007
                    • 1586

                    #10
                    Ya Markus, that's one route I was considering too since I can't get MySQL cache to work on this server.

                    The Database schema is not mine (it's another systems) so adding tables is not an option unless I create a separate database. I don't want to get into double database situation just for caching.

                    @Kovik, what do you mean by PHP cache apps? like Smarty? Ya, that would work, but it will require change to my framework. It's not an "insert header/footer" method but a "insert dynamic content" one.

                    Conclusion: Save static.html file in a /tmp folder for now.

                    Thanks guys,







                    Dan

                    Comment

                    • Markus
                      Recognized Expert Expert
                      • Jun 2007
                      • 6092

                      #11
                      Originally posted by kovik
                      @Markus: I thought that's what the PHP cache apps did. I've never tried any, though.
                      I have no idea about Memcache, but APC caches PHP's opcodes.

                      Comment

                      Working...