Skip to content
This repository has been archived by the owner on Mar 4, 2021. It is now read-only.

Commit

Permalink
Prevent browsers from caching messages/scripts
Browse files Browse the repository at this point in the history
Implement cache control on `messages/scripts` endpoint and script tag to
prevent browsers from caching the resuts and preventing audio playback.
  • Loading branch information
Gipetto committed Aug 20, 2015
1 parent 440b0e2 commit 464c0d3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.markdown
Expand Up @@ -8,6 +8,7 @@
- Fix notification settings save when altering settings as a tenant. (Thanks @AsaadQ)
- Removing obsolete update check.
- Numerous small fixes, code style updates, and docblock fixes of issues found during static analysis.
- Implement cache control on `messages/scripts` endpoint and script tag to prevent caching.


## OpenVBX 1.2.17
Expand Down
10 changes: 8 additions & 2 deletions OpenVBX/controllers/messages/inbox.php
Expand Up @@ -164,8 +164,12 @@ public function scripts($group = false)
$messageIdsJson = '{}';
}

/* TODO: implement JS responding */
header('content-type: text/javascript');
header('Expires: Fri, 22 Mar 1974 06:30:00 GMT');
header('Last-Modified: ' . gmdate( 'D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
echo "$(document).ready(function(){ Message.Player.messageIdsToRecordingURLs = ".
$messageIdsJson."; });";
}
Expand Down Expand Up @@ -196,8 +200,10 @@ private function inbox($group = false)
return;
}

$ts = time();

$this->template->add_js('messages/scripts'.($group? '/'.$group : '').'?'.
http_build_query(compact('max', 'offset')), 'dynamic');
http_build_query(compact('max', 'offset', 'ts')), 'dynamic');

$data['group'] = $group;
$total_items = 0;
Expand Down

0 comments on commit 464c0d3

Please sign in to comment.