A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: PHP/SQL Table Values Caching.. help :(

  1. #1
    Junior Member
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    10

    PHP/SQL Table Values Caching.. help :(

    Hi all, I tried to search for this but when i tried the search on this forum wouldnt work. Basically, I'm making a sort of forum/news-with-comments app in flash and am having problems with caching. My app runs in the browser and uses PHP to get the article titles from the database and put them into a list component.

    When you choose to add a new article, it gets successfully added to the database, but it will not show the new articles in the list unless I open it in a new window or clear my history and temp net files.(I have it set to clear the list and re-retreive the values from the database when an article is posted but the new article doesnt show)

    I have also tried tacking ?nocache= onto the end of the php file calls but that didnt do anything either.. please help

  2. #2
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    you would usually use anti-cache headers within your php script

    However, in an application where data is sent to the server, updates something, and should be reflected in flash, you should simply use POST to send the data, and have the server send back new data for the display in the same transaction

    Musicman

  3. #3
    Junior Member
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    10
    Thanks for your reply, although excuse my newbieness Im not sure what you mean. I've been working on this with another guy who has been doing the PHP bits and I'm doing the flash and we've been learning as we go.

    At the moment for populating the list with the titles we have a PHP file to get them, a PopulateList() function which uses the LoadVars.load() function to communicate to with the PHP. The returned data is then added to the list component by a PopulateListHandler() function that I made.

    To submit the articles to the database we have a separate PHP file, and a PostArticle() function which uses LoadVars.sendAndLoad() using "POST" to send the data to the PHP. (btw, this is using a separate LoadVars object to the PopulateList() function if that matters) I then have a PostArticleHandler() function that determines if the posting was successful or not and then calls the PopulateList() function once again.

    Is there a way to get this to work without changing what I've done too much, which I'm assuming doing it all in the same transaction would entail?

  4. #4
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    your description makes it clear that you really wait for the data before you refresh...
    Now have the php guy add these lines to the script
    header("Cache-control: no-cche");
    header("Pragma: no-cche");
    header("Expires: Mon, 01 Jan 2000 00:00 GMT");

    Musicman

  5. #5
    Junior Member
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    10
    Thanks for your help. I'll pass it on to him.

  6. #6
    Arabic Flasher
    Join Date
    Jul 2001
    Location
    Saudi Arabia
    Posts
    190
    hi

    also this'll work 100% with http 1.0 & http 1.1

    and here an example

    Code:
    <?php
    
    $rand1 = rand(500,20000);
    
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0", false);
    header("Pragma: no-cache");
    header("Cache-control: private");
    
    echo $rand1;
    
    ?>
    for testing:

    http://www.flashyat.com/testcache.php

    thanx to Musicman i was asked this qustion before, i add some new line of code from php.net


    http://www.flashyat.com/

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center