Commit ca0c07a8 authored by Jordan Michaels's avatar Jordan Michaels

Release 2018021901 - Issues 8,9

parent 0b70f998
......@@ -7,3 +7,13 @@ Versions are recorded in YYYYMMDDnn format. Please include latest versions at th
## 2018011901
* Initial alpha release for internal testing of caching system.
## 2018021301
* [NEW] Update Vivio-Swift HTML footer message to state if page was not cached due to exclude rule - Issue 1
* [NEW] Added and updated refresh events for pages, tags, and categories - Issue 6
* [NEW] Refresh Events now re-create preload cache if preload caching is enabled - Issue 7
* [NEW] The Preload Cache process should now run on plugin activation - Issue 8
## 2018021901
* [UPGRADE] The Vivio Swift Preload Cache is now a non-blocking event, and runs quietly in the background - Issue 9
* [FIX] The Preload Cache process should now actually run on plugin activation - Issue 8
# [Vivio Swift](https://code.viviotech.net/jordan/vivio-swift)
The Vivio Swift WordPress plugin alpha release provides a comprehensive page caching system that completely bypasses PHP using .htaccess files. The primary goal of this release is to demonstrate and test the page caching systems, exclusion system, logging features, and refresh events.
The Vivio Swift WordPress plugin (beta) provides a comprehensive page caching system that completely bypasses PHP using .htaccess files. The primary goal of this realease is to demonstrate and test the page caching systems, exclusion system, logging features, and refresh events.
## Page Caching
......@@ -31,13 +31,13 @@ The Vivio Swift WordPress plugin alpha release provides a comprehensive page cac
## Planned Features
* Image compression using GD or Vivio service
* CSS minification (compression)
* JS minification (compression)
* CSS combination to reduce the number of HTTP requests to a server
* JS combination to reduce the number of HTTP requests to a server
* Asynchronous loading of Google Fonts
* Disabling of render-blocking JS
* Image compression using GD or Vivio service
# Installation
......
No preview for this file type
......@@ -5,14 +5,21 @@ abstract class Vivio_Swift_Admin_Messages
function show_msg_settings_updated()
{
echo '<div id="message" class="updated fade"><p><strong>';
_e('Settings successfully updated.','all-in-one-wp-security-and-firewall');
_e('Settings successfully updated.','vivio-swift');
echo '</strong></p></div>';
}
static function show_msg_preload_scheduled()
{
echo '<div id="message" class="updated fade"><p><strong>';
_e('New preload cache process has been scheduled...','vivio-swift');
echo '</strong></p></div>';
}
static function show_msg_record_deleted_st()
{
echo '<div id="message" class="updated fade"><p><strong>';
_e('The selected record(s) deleted successfully!','all-in-one-wp-security-and-firewall');
_e('The selected record(s) deleted successfully!','vivio-swift');
echo '</strong></p></div>';
}
......
......@@ -98,9 +98,9 @@ class Vivio_Swift_Cache_Menu extends Vivio_Swift_Admin_Messages
// set and save settings
if (isset($_POST["vivio_swift_cache_enabled"])){
Vivio_Swift_Cache_OnAccess::enable();
$vivio_swift_global->cache_obj->cache_onaccess->enable();
} else {
Vivio_Swift_Cache_OnAccess::disable();
$vivio_swift_global->cache_obj->cache_onaccess->disable();
}
......@@ -109,7 +109,7 @@ class Vivio_Swift_Cache_Menu extends Vivio_Swift_Admin_Messages
if (isset($_POST['vivio_swift_cache_clear_submit']))
{
Vivio_Swift_Cache_OnAccess::clear();
$vivio_swift_global->cache_obj->cache_onaccess->clear();
$this->show_msg_settings_updated();
}
......@@ -157,7 +157,7 @@ class Vivio_Swift_Cache_Menu extends Vivio_Swift_Admin_Messages
<tr valign="top">
<th scope="row"><?php _e('Current Cache', 'vivio-swift')?>:</th>
<td>
<span class="description"><?php echo Vivio_Swift_Utility_File::get_file_count().' Files ('.Vivio_Swift_Utility_File::get_directory_size().')'; ?></span>
<span class="description"><?php echo $vivio_swift_global->util_file->get_file_count().' Files ('.$vivio_swift_global->util_file->get_directory_size().')'; ?></span>
</td>
</tr>
</table>
......@@ -179,7 +179,7 @@ class Vivio_Swift_Cache_Menu extends Vivio_Swift_Admin_Messages
if (isset($_POST['vivio_swift_cache_clear_submit']))
{
Vivio_Swift_Cache_Preload::clear();
$vivio_swift_global->cache_obj->cache_preload->clear();
$this->show_msg_settings_updated();
}
......@@ -190,15 +190,12 @@ class Vivio_Swift_Cache_Menu extends Vivio_Swift_Admin_Messages
// if preload is enabled, calc the expiration date
if (($preload_cache_enabled=='1') && ($preload_last_run_date!='')){
$cache_expires_in_txt = Vivio_Swift_Utility_Date::format_interval($preload_last_run_datetime);
$cache_expires_in_txt = $vivio_swift_global->util_date->format_interval($preload_last_run_datetime);
} else {
$cache_expires_in_txt = "No Preload Cache on record.";
}
if (
isset($_POST['vivio_swift_save_preload_cache_settings']) ||
isset($_POST['vivio_swift_preload_force_refresh'])
)
if (isset($_POST['vivio_swift_save_preload_cache_settings']))
{
$error = '';
......@@ -209,11 +206,6 @@ class Vivio_Swift_Cache_Menu extends Vivio_Swift_Admin_Messages
wp_die("Error: Nonce check failed in preload settings.");
}
if (isset($_POST['vivio_swift_preload_force_refresh'])){
// force a preload cache refresh
$vivio_swift_global->cache_obj->cache_preload->create_preload_cache(1);
}
$vivio_swift_preload_cache_expire_hours_val = sanitize_text_field($_POST['vivio_swift_preload_cache_expire_hours']);
if(!is_numeric($vivio_swift_preload_cache_expire_hours_val))
{
......@@ -232,9 +224,9 @@ class Vivio_Swift_Cache_Menu extends Vivio_Swift_Admin_Messages
// set and save settings
if (isset($_POST["vivio_swift_preload_cache_enabled"])){
Vivio_Swift_Cache_Preload::enable();
$vivio_swift_global->cache_obj->cache_preload->enable();
} else {
Vivio_Swift_Cache_Preload::disable();
$vivio_swift_global->cache_obj->cache_preload->disable();
}
$vivio_swift_global->configs->set_value('vivio_swift_preload_cache_expire_hours',absint($vivio_swift_preload_cache_expire_hours_val));
......@@ -243,6 +235,22 @@ class Vivio_Swift_Cache_Menu extends Vivio_Swift_Admin_Messages
$this->show_msg_settings_updated();
}
if (isset($_POST['vivio_swift_preload_force_refresh']))
{
// verify nonce
$nonce = $_REQUEST['_wpnonce'];
if (!wp_verify_nonce($nonce, 'vivio_swift_preload_cache_nonce')) {
$vivio_swift_global->debug_logger->log_debug("Nonce check failed in preload settings.", 4);
wp_die("Error: Nonce check failed in preload settings.");
}
if (isset($_POST['vivio_swift_preload_force_refresh'])){
// force a preload cache refresh
$vivio_swift_global->cache_obj->cache_preload->create_preload_cache(1);
$this->show_msg_preload_scheduled();
}
}
?>
<div id="vivio-swift-container">
......@@ -310,7 +318,7 @@ class Vivio_Swift_Cache_Menu extends Vivio_Swift_Admin_Messages
<tr valign="top">
<th scope="row"><?php _e('Current Cache', 'vivio-swift')?>:</th>
<td>
<span class="description"><?php echo Vivio_Swift_Utility_File::get_file_count().' Files ('.Vivio_Swift_Utility_File::get_directory_size().')'; ?></span>
<span class="description"><?php echo $vivio_swift_global->util_file->get_file_count().' Files ('.$vivio_swift_global->util_file->get_directory_size().')'; ?></span>
</td>
</tr>
</table>
......
......@@ -92,7 +92,7 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages
// if preload is enabled, calc the expiration date
if (($preload_cache_enabled=='1') && ($preload_last_run_date!='')){
$cache_expires_in_txt = Vivio_Swift_Utility_Date::format_interval($preload_last_run_datetime);
$cache_expires_in_txt = $vivio_swift_global->util_date->format_interval($preload_last_run_datetime);
} else {
$cache_expires_in_txt = "No Preload Cache on record.";
}
......@@ -106,7 +106,7 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages
wp_die("Error: Nonce check failed when attempting to clear cache.");
}
Vivio_Swift_Cache_Preload::clear();
$vivio_swift_global->cache_obj->cache_preload->clear();
$this->show_msg_settings_updated();
}
......@@ -120,6 +120,7 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages
// force a preload cache refresh
$vivio_swift_global->cache_obj->cache_preload->create_preload_cache(1);
$this->show_msg_preload_scheduled();
}
if (isset($_POST['vivio_swift_cache_dashboard_submit']))
......@@ -195,7 +196,7 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages
<tr valign="top">
<th scope="row"><?php _e('Current Cache', 'vivio-swift')?>:</th>
<td>
<span class="description"><?php echo Vivio_Swift_Utility_File::get_file_count().' Files ('.Vivio_Swift_Utility_File::get_directory_size().')'; ?></span>
<span class="description"><?php echo $vivio_swift_global->util_file->get_file_count().' Files ('.$vivio_swift_global->util_file->get_directory_size().')'; ?></span>
</td>
</tr>
</table>
......@@ -621,64 +622,7 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages
</div>
</div>
<?php /*
<!-- view logs option -->
<div class="postbox">
<h3 class="hndle">
<label for="title"><?php _e('View Logs for the Vivio Swift Plugin', 'vivio-swift');?></label>
</h3>
<div class="inside">
<form action=""
id="vivio_swift_dashboard_logs"
method="POST">
<?php wp_nonce_field('vivio-swift-logs-nonce'); ?>
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('Log File', 'vivio-swift')?>:</th>
<td>
<select id="vivio_swift_log_file" name="vivio_swift_log_file">
<option
value=""><?php _e('--Select a file--', 'vivio-swift')?></option>
<option
value="vivio-swift-log.txt" <?php selected($file_selected, 'vivio-swift-log.txt'); ?>>
vivio-swift-log
</option>
<option
value="vivio-swift-log-cron-job.txt" <?php selected($file_selected, 'vivio-swift-log-cron-job.txt'); ?>>
vivio-swift-log-cron-job
</option>
</select>
<span class="description"><?php _e('Select one of the log files to view the contents', 'vivio-swift'); ?></span>
</td>
</tr>
</table>
<input type="submit" name="vivio_swift_view_logs"
value="<?php _e('View Logs', 'vivio-swift')?>"
class="pure-button"/>
</form>
</div>
</div>
?>
<?php
if (isset($_POST['vivio_swift_view_logs']) && $file_selected)//Do form submission tasks
{
//Check nonce before doing anything
$nonce = $_REQUEST['_wpnonce'];
if (!wp_verify_nonce($nonce, 'vivio-swift-logs-nonce')) {
$vivio_swift_global->debug_logger->log_debug("Nonce check failed while attempting to view logs.", 4);
wp_die("Error: Nonce check failed while attempting to view logs.");
}
//Let's make sure that the file selected can only ever be the correct log file of this plugin.
$vivio_swift_valid_log_files = array('vivio-swift-log.txt', 'vivio-swift-log-cron-job.txt');
if(!in_array($file_selected, $vivio_swift_valid_log_files)){
$file_selected = '';
unset($_POST['vivio_swift_view_logs']);
wp_die(__('Error: The selected file is not a Vivio Swift log file.','vivio-swift'));
}
*/
if (!empty($file_selected)) {
?>
<div class="postbox">
......@@ -691,7 +635,7 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages
$vivio_swift_log_dir = VIVIO_SWIFT_PATH . '/logs';
$log_file = $vivio_swift_log_dir . '/' . $file_selected;
if (file_exists($log_file)) {
$log_contents = Vivio_Swift_Utility_File::get_file_contents($log_file);
$log_contents = $vivio_swift_global->util_file->get_file_contents($log_file);
} else {
$log_contents = '';
}
......@@ -712,11 +656,8 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages
</form>
</div>
</div>
<?php
}
// }
}
function render_tab4()
......@@ -806,7 +747,7 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages
<div class="inside">
<textarea class="text_area_file_output width_full margin_10_0" rows="20" readonly><?php
$htaccess_contents = Vivio_Swift_Utility_Htaccess::display_htaccess();
$htaccess_contents = $vivio_swift_global->util_htaccess->display_htaccess();
if (empty($htaccess_contents)){
echo __('Vivio Swift has nothing to write to .htaccess', 'vivio-swift');
......@@ -842,14 +783,16 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages
// reset options
Vivio_Swift_Config_Settings::reset_to_defaults();
// clear cache directory
Vivio_Swift_Utility_File::clear_cache_dir();
$vivio_swift_global->util_file->clear_cache_dir();
// reset .htaccess
Vivio_Swift_Utility_Htaccess::delete_from_htaccess();
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
$vivio_swift_global->util_htaccess->delete_from_htaccess();
$vivio_swift_global->util_htaccess->write_to_htaccess();
// reset logs
$vivio_swift_global->debug_logger->reset_log_file('1');
$vivio_swift_global->debug_logger->reset_log_file('2');//cron
//$vivio_swift_global->debug_logger->reset_log_file('2');//cron
$preload_enabled = ($this->configs->get_value('vivio_swift_preload_cache_enabled')=='1')?true:false;
if ($preload_enabled){wp_schedule_single_event(time(), 'vivio_swift_schedule_preload_cache');}
$this->show_msg_settings_updated();
}
......
......@@ -27,12 +27,14 @@ class Vivio_Swift_Activator{
// configure cron handlers
/*
if ( !wp_next_scheduled('vivio_swift_hourly_cron_event') ) {
wp_schedule_event(time(), 'hourly', 'vivio_swift_hourly_cron_event'); //schedule an hourly cron event
}
if ( !wp_next_scheduled('vivio_swift_daily_cron_event') ) {
wp_schedule_event(time(), 'daily', 'vivio_swift_daily_cron_event'); //schedule an daily cron event
}
*/
}
}
......@@ -4,7 +4,7 @@ class Vivio_Swift_Cache_Excludes
function __construct()
{
global $vivio_swift_global;
}
function get_cookie_values()
......@@ -25,7 +25,7 @@ class Vivio_Swift_Cache_Excludes
$vivio_swift_global->configs->set_value('vivio_swift_cache_exclude_cookie_values',array_values($arr_cookie_values));
$vivio_swift_global->configs->save_config();
}
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
$vivio_swift_global->util_htaccess->write_to_htaccess();
}
function remove_cookie_value($val)
......@@ -38,8 +38,7 @@ class Vivio_Swift_Cache_Excludes
}
$vivio_swift_global->configs->set_value('vivio_swift_cache_exclude_cookie_values',array_values($arr_cookie_values));
$vivio_swift_global->configs->save_config();
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
}
$vivio_swift_global->util_htaccess->write_to_htaccess(); }
//returns true if passed cookie value is listed in required cookie exclusions
function cookie_check_required_value($val)
......@@ -69,7 +68,7 @@ class Vivio_Swift_Cache_Excludes
$vivio_swift_global->configs->set_value('vivio_swift_cache_exclude_user_agent_values',array_values($arr_user_agent_values));
$vivio_swift_global->configs->save_config();
}
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
$vivio_swift_global->util_htaccess->write_to_htaccess();
}
function remove_user_agent_value($val)
......@@ -82,7 +81,7 @@ class Vivio_Swift_Cache_Excludes
}
$vivio_swift_global->configs->set_value('vivio_swift_cache_exclude_user_agent_values',array_values($arr_user_agent_values));
$vivio_swift_global->configs->save_config();
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
$vivio_swift_global->util_htaccess->write_to_htaccess();
}
//returns true if passed user_agent value is listed in required user_agent exclusions
......@@ -115,7 +114,7 @@ class Vivio_Swift_Cache_Excludes
$vivio_swift_global->configs->save_config();
}
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::add_path_is_value() - writing .htaccess file...", 1);
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
$vivio_swift_global->util_htaccess->write_to_htaccess();
}
function remove_path_is_value($val)
......@@ -132,7 +131,7 @@ class Vivio_Swift_Cache_Excludes
}
$vivio_swift_global->configs->set_value('vivio_swift_cache_exclude_path_is_values',array_values($arr_path_is_values));
$vivio_swift_global->configs->save_config();
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
$vivio_swift_global->util_htaccess->write_to_htaccess();
}
function get_path_ends_with_values()
......@@ -153,7 +152,7 @@ class Vivio_Swift_Cache_Excludes
$vivio_swift_global->configs->set_value('vivio_swift_cache_exclude_path_ends_with_values',array_values($arr_path_ends_with_values));
$vivio_swift_global->configs->save_config();
}
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
$vivio_swift_global->util_htaccess->write_to_htaccess();
}
function remove_path_ends_with_value($val)
......@@ -170,7 +169,7 @@ class Vivio_Swift_Cache_Excludes
}
$vivio_swift_global->configs->set_value('vivio_swift_cache_exclude_path_ends_with_values',array_values($arr_path_ends_with_values));
$vivio_swift_global->configs->save_config();
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
$vivio_swift_global->util_htaccess->write_to_htaccess();
}
function get_path_contains_values()
......@@ -191,7 +190,7 @@ class Vivio_Swift_Cache_Excludes
$vivio_swift_global->configs->set_value('vivio_swift_cache_exclude_path_contains_values',array_values($arr_path_contains_values));
$vivio_swift_global->configs->save_config();
}
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
$vivio_swift_global->util_htaccess->write_to_htaccess();
}
function remove_path_contains_value($val)
......@@ -208,7 +207,7 @@ class Vivio_Swift_Cache_Excludes
}
$vivio_swift_global->configs->set_value('vivio_swift_cache_exclude_path_contains_values',array_values($arr_path_contains_values));
$vivio_swift_global->configs->save_config();
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
$vivio_swift_global->util_htaccess->write_to_htaccess();
}
// returns error message is condition is hit. otherwise simply returns false.
......@@ -245,7 +244,7 @@ class Vivio_Swift_Cache_Excludes
// cookie excludes
// forced refreshes do not need to process cookies
if(!$force){
$arr_cookie_values=Vivio_Swift_Cache_Excludes::get_cookie_values();
$arr_cookie_values=$vivio_swift_global->cache_obj->cache_excludes->get_cookie_values();
foreach ($arr_cookie_values as $i => $value) {
foreach ((array)$_COOKIE as $cookie_key => $cookie_value){
$searchval='/'.$value.'/i';
......@@ -266,7 +265,7 @@ class Vivio_Swift_Cache_Excludes
// user agent excludes
if ($vivio_swift_global->configs->get_value('vivio_swift_enable_cache_comment')=='1')
{
$arr_user_agent_values=Vivio_Swift_Cache_Excludes::get_user_agent_values();
$arr_user_agent_values=$vivio_swift_global->cache_obj->cache_excludes->get_user_agent_values();
foreach ($arr_user_agent_values as $i => $value) {
if(strpos($_SERVER['HTTP_USER_AGENT'],$value)!==false){
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - Exclude 'user agent' rule hit for user agent value: '".$value."' [SKIPPING]", 2);
......@@ -277,7 +276,7 @@ class Vivio_Swift_Cache_Excludes
if ($vivio_swift_global->configs->get_value('vivio_swift_cache_exclude_path_is')=='1')
{
$arr_path_is_values=Vivio_Swift_Cache_Excludes::get_path_is_values();
$arr_path_is_values=$vivio_swift_global->cache_obj->cache_excludes->get_path_is_values();
foreach ($arr_path_is_values as $i => $value) {
$value = '/'.$value.'/';
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - Testing URL: ".$url, 0);
......@@ -293,7 +292,7 @@ class Vivio_Swift_Cache_Excludes
if ($vivio_swift_global->configs->get_value('vivio_swift_cache_exclude_path_ends_with')=='1')
{
$arr_path_ends_with_values=Vivio_Swift_Cache_Excludes::get_path_ends_with_values();
$arr_path_ends_with_values=$vivio_swift_global->cache_obj->cache_excludes->get_path_ends_with_values();
foreach ($arr_path_ends_with_values as $i => $value) {
$searchval='/\.('.$value.')$/';
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - Testing URL: ".$url, 0);
......@@ -309,7 +308,7 @@ class Vivio_Swift_Cache_Excludes
if ($vivio_swift_global->configs->get_value('vivio_swift_cache_exclude_path_contains')=='1')
{
$arr_path_contains_values=Vivio_Swift_Cache_Excludes::get_path_contains_values();
$arr_path_contains_values=$vivio_swift_global->cache_obj->cache_excludes->get_path_contains_values();
foreach ($arr_path_contains_values as $i => $value) {
$searchval='/^.*('.$value.').*$/';
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - Testing URL: ".$url, 0);
......
......@@ -9,40 +9,26 @@ class Vivio_Swift_Cache_OnAccess
function enable()
{
global $vivio_swift_global;
// set config option to enabled
$vivio_swift_global->configs->set_value('vivio_swift_cache_enabled','1');//Checkbox
$vivio_swift_global->configs->save_config();
// update htaccess
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
// log it
$vivio_swift_global->util_htaccess->write_to_htaccess();
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_OnAccess::enable() - OnAccess Cache enabled.", 0);
}
function disable()
{
global $vivio_swift_global;
$vivio_swift_global->configs->set_value('vivio_swift_cache_enabled','');//Checkbox
$vivio_swift_global->configs->save_config();
// update htaccess
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
// log it
$vivio_swift_global->util_htaccess->write_to_htaccess();
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_OnAccess::enable() - OnAccess Cache disabled.", 0);
}
function clear()
{
global $vivio_swift_global;
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_OnAccess::clear() - Clearing OnAccess Cache...", 1);
Vivio_Swift_Utility_File::clear_cache_dir();
$vivio_swift_global->util_file->clear_cache_dir();
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_OnAccess::clear() - Resetting Preload Cache Last Run date...", 1);
$vivio_swift_global->configs->set_value('vivio_swift_preload_last_run_date','');
$vivio_swift_global->configs->save_config();
......@@ -51,7 +37,6 @@ class Vivio_Swift_Cache_OnAccess
function create_page_cache()
{
global $vivio_swift_global;
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_OnAccess::create_page_cache() - creating page cache...",0);
ob_start(array($this, "create_page_cache_closer"));
}
......@@ -60,13 +45,9 @@ class Vivio_Swift_Cache_OnAccess
{
global $vivio_swift_global;
global $wp;
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_OnAccess::create_page_cache_closer() - Initializing closer...",0);
// process exclusions
if ($exclude_response = Vivio_Swift_Cache_Excludes::process_cache_excludes($url)){
// if the url matches one of our excludes, don't cache it, just move on.
// check to see if we're set to include a message or not
$exclude_response = $vivio_swift_global->cache_obj->cache_excludes->process_cache_excludes($url,$force);
if ($exclude_response){
if($vivio_swift_global->configs->get_value('vivio_swift_enable_cache_comment')=='1'){
return $response."<!-- [Vivio Swift] ".$exclude_response." -->";
} else {
......
......@@ -3,46 +3,32 @@ class Vivio_Swift_Cache_Preload
{
function __construct()
{
add_action('vivio_swift_schedule_preload_cache', array(&$this, 'schedule_create_preload_cache'));
}
function enable()
{
global $vivio_swift_global;
// set config option to enabled
$vivio_swift_global->configs->set_value('vivio_swift_preload_cache_enabled','1');//Checkbox
$vivio_swift_global->configs->save_config();
// update htaccess
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
// log it
$vivio_swift_global->util_htaccess->write_to_htaccess();
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Preload::enable() - Preload Cache enabled.", 1);
}
function disable()
{
global $vivio_swift_global;
$vivio_swift_global->configs->set_value('vivio_swift_preload_cache_enabled','');//Checkbox
$vivio_swift_global->configs->save_config();
// update htaccess
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
// log it
$vivio_swift_global->util_htaccess->write_to_htaccess();
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Preload::enable() - Preload Cache disabled.", 1);
}
function clear()
{
global $vivio_swift_global;
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Preload::clear() - Clearing Preload Cache...", 1);
Vivio_Swift_Utility_File::clear_cache_dir();
$vivio_swift_global->util_file->clear_cache_dir();
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Preload::clear() - Resetting Preload Cache Last Run date...", 1);
$vivio_swift_global->configs->set_value('vivio_swift_preload_last_run_date','');
$vivio_swift_global->configs->save_config();
......@@ -154,15 +140,16 @@ class Vivio_Swift_Cache_Preload
foreach ($urls as $url){
if ($exclude_response = Vivio_Swift_Cache_Excludes::process_cache_excludes($url,$force)){
// if theres a response, it means the URL should be excluded so just log and move on.
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Preload::create_preload_cache() - Exclude rule hit: ".$exclude_response."[SKIPPING]", 1);
continue;
}
$exclude_response = $vivio_swift_global->cache_obj->cache_excludes->process_cache_excludes($url,$force);
if($exclude_response){continue;} // a response means url should be excluded.
// send urls off to the caching process
Vivio_Swift_Cache::cache_url_with_agent($url, VIVIO_SWIFT_CACHE_BOT_NAME);
// send url off to the caching process
// $vivio_swift_global->cache_obj->cache_url_with_agent($url, VIVIO_SWIFT_CACHE_BOT_NAME);
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Preload::create_preload_cache() - Pushing URL to queue: ".$url, 1);
$vivio_swift_global->proc_preload->push_to_queue($url);
}
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Preload::create_preload_cache() - Queueing complete. Dispatching preload process queue.", 1);
$vivio_swift_global->proc_preload->save()->dispatch();
// caching process finished. record time.
$date = new DateTime();
......@@ -210,22 +197,11 @@ class Vivio_Swift_Cache_Preload
function schedule_create_preload_cache()
{
global $vivio_swift_global;
// IMPORTANT: Not currently using WP-CRON for preload cache as many folks disable it and it is somewhat unreliable ~JM
// TODO: clean some of these checks since they're probably not needed
// don't cache the admin user
if (!is_admin()){