ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Cache Problem - Is there any way to clear cache programatically?

December 04, 2008 5:07pm

Subscribe [3]
  • #1 / Dec 04, 2008 5:07pm

    Paul Price

    4 posts

    I’ve got a web form that upon submission changes a custom field in the exp_weblog_data table via an SQL call within PHP code. But when the page redisplays (pulled via EE Weblog tag), the old data still shows. The entry being changed is a “child” entry within a prent/child weblog entry relationship.

    I’ve debugged my problem down to EE’s caching of the relationship data. If I clear the “relationship cache” via the EE admin panel the correct data is displayed on the page.

    Is there any way to clear this cache via php code (instead of using the admin panel) so that the page will show the correct data right after I update the exp_weblog_data table?

  • #2 / Dec 04, 2008 5:33pm

    Ingmar

    29245 posts

    Are you caching your tags? Or templates? Also, what version and build of EE are you on?

  • #3 / Dec 04, 2008 6:11pm

    Paul Price

    4 posts

    EE v1.6.0

    Not 100% sure what all the various caching options I can set are, and where I would set them. Here’s what I can find:

    1.. Caching on the individual template (template group => template preferences => enable caching) is set to No

    2.. Enable SQL Query Caching (admin => system preferences => database settings) is set to No

    3.. Clear all caches when new entries are posted? (admin => weblog administration => global weblog preferences) is set to Yes

    4.. Cache Dynamic Section Queries? (admin => weblog administration => global weblog preferences) is set to No

    Am I missing anything?

    All I know is that when I clear the “Cached Relationship Entries” via admin => utilities => clear caches data, and then refresh my page, the updated content appears. If I don’t clear this cache, the page displays the old data, despite the fact that if I look in the exp_weblog_data table itself the new content exists there in the custom field I’m updating via the form.

  • #4 / Dec 04, 2008 6:36pm

    Ingmar

    29245 posts

    I am not saying this is the issue, but EE 1.6.0 is a rather old version. For reasons of security alone we recommend an upgrade to EE 1.6.6; this should also help shaking out any file corruption issues.

  • #5 / Dec 04, 2008 8:32pm

    Paul Price

    4 posts

    We’re planning on upgrading once we have a development break, but we’re running white hot right now launching new functionality and don’t want to risk anything crashing - we’re pushing around 1 million page views per month with a lot of revenue at stake. Would really like to get this working on the current platform now and then we’ll upgrade in early January.

  • #6 / Dec 04, 2008 8:47pm

    Greg Aker

    6022 posts

    Paul:

    Take a peek at $FNS->clear_caching() in the functions class.

  • #7 / Dec 05, 2008 11:35am

    Paul Price

    4 posts

    That looks like it should do the trick. But the function isn’t recognized within my template. I’m assuming I have to call in (ex php “require” statement) an external file in order to get this working. Where does the function class reside? NOTE: be patient with me - just a php hacker, not formally trained programmer 😊

  • #8 / Dec 05, 2008 11:51am

    Ingmar

    29245 posts

    Yes, Paul, you’ll have to define the Class globally. Try that:

    <?php global $FNS;
    $FNS->clear_caching('all');
    ?>
  • #9 / Dec 05, 2008 11:54am

    Paul Price

    4 posts

    That did the trick…thanks!

  • #10 / Dec 05, 2008 12:03pm

    Ingmar

    29245 posts

    Glad to hear it 😊 You still should consider upgrading as soon as your schedule permits. Don’t hesitate to post again as needed.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases