Tom
Tom

Reputation: 7586

Is there a way to trigger immediate invalidation of a PHP file system cache if MYSQL data changes?

I have a simple site on a shared hosting service and I use basic PHP output caching (writing HTML output to files). The data of the site does not change often, but when it does then only I make changes, so the site has no update interface, because it does not need one, I simply log in to the phpmyadmin interface and upload the modifications as SQL statements.

This works well, the only problem is the changes do not appear immediately on the site, only when the cache time expires. Is there some way to trigger cache invalidation from mysql, so the caches are cleared when I change data in the database. For example, I could add one more sql line to the update which would somwehow call an external program in the home directory if it's possible, but is it?

If it's not then is there some clever way for MYSQL to notify the PHP side about a data update without PHP having to connect to the database (if there is a cached version of the page then it uses that and does not connect to the database, because that is the point).

Upvotes: 0

Views: 373

Answers (1)

penartur
penartur

Reputation: 9912

is there some clever way for MYSQL to notify the PHP side about a data update without PHP having to connect to the database

There is not, and you should not want this.

You may write a special PHP script on your site which will invalidate the cache, and call it manually each time you update the DB. Or you may store your cache in DB (rather than in files).

Upvotes: 1

Related Questions