Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Oct 2008
    Posts
    255
    Thanks
    113
    Thanked 0 Times in 0 Posts

    Database Information and Page Caching

    What exactly goes on when your browser caches a page that displays information from a database? The reason I'm asking is because I use a PHP session to cache my homepage. When I first experimented with that type of code, I used it on a page that just contained an HTML paragraph and no database info. I added a second paragraph and uploaded the new page, went to it, and nothing had changed because it was still cached. But when my session expired, then the new paragraph began to show.

    But on my homepage, the information that comes from the database doesn't update when the session expires for some reason. It still remains cached, and I have to clear my cache and reload the page to get it to update. So is there an issue regarding databases and browser caches that I'm unaware of?

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,021
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    LOL!
    Do not immediately assume the syntax is in error.
    It's a good thing you said that...because otherwise I wouldn't have noticed your change!

    That's the normal way to make a query with JSP code, so I would have glossed over it. <grin/>

    ANYWAY...

    I'm not aware that the server *SHOULD* be doing ANY caching of a page. Certainly wouldn't expect it to with JSP or ASP. And only when explicitly requested with ASP.NET.

    Makes me think that *probably* the caching is occurring all in the browser. And easy way to both test and fix that is to append a random number or a time stamp to the query string in the URL.

    For example, if you are using a form posting to get to the server code, do something like:
    Code:
    <form action="nameOfSamePage.php?junk=<?= someRandomNumber ?>" >
    ...
    (or you could append the random number with javascript code, or you could use a hidden form field, or...) Use a similar trick if you are using an <A HREF=...> link.

    This forces the browser to believe that indeed it's getting a different page than it got before, so it *will* reload from the server.

    If that fixes it, then indeed it's been all a browser issue. If not, then post back and maybe we can come up with other ideas.

  • #3
    Regular Coder
    Join Date
    Oct 2008
    Posts
    255
    Thanks
    113
    Thanked 0 Times in 0 Posts
    I'm going to go ahead and post my code in case anyone sees an error, because I have no idea how to do what you just said If you don't see an error in my code, do you mind walking me through what you instructed to do?

    PHP Code:
    session_name('UH_Cache');
      
    session_set_cookie_params(1200);
      
    session_cache_limiter('public');
      
    session_cache_expire(20);
      
    session_start(); 

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,021
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    I *assumed* (sorry! dangerous practice!) that one gets *to* this page via a link (e.g., <a href="....">) or <form> posting from another page (or pages).

    So the randomizing tail you plunk the end of the URL has to be on that *other* page (or pages).

    If people always just type in the URL to this page, then I don't know a good solution offhand.

  • #5
    Regular Coder
    Join Date
    Oct 2008
    Posts
    255
    Thanks
    113
    Thanked 0 Times in 0 Posts
    Dang. All right, thanks I tried it again today on a test page that just used HTML paragraphs, and like when I first tested it, it worked fine. I dunno why the database is affecting it that way.

    I'll leave this thread unmarked in case anyone else has an idea as to what is wrong.

  • #6
    New to the CF scene
    Join Date
    May 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Please help me .....

    Hi to all...

    I am new to this forum and its my first post i am in great trouble i am a student and i have few questions please some one answer them these are as under:

    1. What is page caching in database server and clint enviroment and how it happens ?
    2. Why in page caching when we request full whole page retrived from memory if we need just some columns and why in tuple caching full tuples gets retrieved if some small data required by query?
    3. Why semantic caching is better then both of these aproaches ?

    I will be really thankful please some one help me


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •