Jump to content

Don't cache custom blocks


JEFF MACK

Recommended Posts

Posted

I created a custom block, and the caching is turned off in the area where the content is. I am updating the content dynamically directly into the database from an update statement. Those changes are not showing. How can I make sure that I see the updated information. If I just hit save in the admin area, it updates, how can this be done automatically.

I see it says...
If your block contains dynamic elements, such as member data, database counts, etc, you will need to prevent this block from being cached.


Anyone know how to make sure that whatever is updated in the database table, that it shows instantly with no caching?

Posted

As long as the block cache is off it should change information upon save instantly. I've tested this in my 4.0.4 installs and they all work. You may want to submit a bug report or submit a ticket for further investigation.

Posted

Hmm, so i thought it was "off", now I flicked the switch so that it is green, now it is updating.  Is that correct?  The switch should be green, not grey?

The switch should be greyed out as you want caching disabled. With it green, the caching is enabled and your block will be cached.

Posted

The switch should be greyed out as you want caching disabled. With it green, the caching is enabled and your block will be cached.

​I guess its a bug then, I am doing an update directly to the record in the database, and if I refresh the page, it doesn't update the page.  I need to go to the blocks section and just hit save on the block, then it updates.  I need it to update on the fly.

Posted

As long as the block cache is off it should change information upon save instantly. I've tested this in my 4.0.4 installs and they all work. You may want to submit a bug report or submit a ticket for further investigation.

​It does update if I hit save, the thing is, I am updating this outside the system so I am not actually hitting the save button, I run a script that is producing the HTML for the custom block.

Posted

​I guess its a bug then, I am doing an update directly to the record in the database, and if I refresh the page, it doesn't update the page.  I need to go to the blocks section and just hit save on the block, then it updates.  I need it to update on the fly.

​Sorry for the late response, wanted to find time to test before replying. 

Ran a test with a simple update statement increasing an integer on each query statement in a custom block with the cache off and it is updating my database on each page load. I also ran it with cache on and it only updated on initial run (after save), which is what should happen. This was tested on 4.0.5 though as I kind of mapped it into a bunch of other tests I'm running. 4.0.5 should be out soon, if your problem is not fixed then please let me know and I can take a quick peak at your code.

Posted

Handled via ticket:)

The problem is, that you can't run a simple upgrade on the block content, because ips4 is storing the compiled template in the datastore.

 

 

If any body else needs this => the following code will delete the compiled template, which will force the rebuild on the next block usage
 

\IPS\cms\Block::deleteCompiled($id) 

 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...