I am in the process of building a custom CMS in PHP, using TinyMCE as my Rich Text Editor. I had a odd problem where after saving my changes and being redirected back to my editor, my changes weren’t being refreshed. I had to shift + reload the page to see the new content. I tried everything I could think of with no success, when a user on the Freenode servers directed me to this code.
// Disable caching function http_last_modified( $time = NULL ) { if ( $time === NULL ) $time = time(); $new_last_modified = gmdate( 'D, d M Y H:i:s' , $time ) . ' GMT'; if ( isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) { $if_modified_since = preg_replace( '/;.*$/' , '' , $_SERVER['HTTP_IF_MODIFIED_SINCE'] ); if ( $if_modified_since == $new_last_modified ) { header( 'HTTP/1.0 304 Not Modified' ); exit(0); } } header( "Last-Modified: $new_last_modified" ); } http_last_modified();
It works like a charm!