Add timestamp as get param to resources

Should force clients to get new files each time thy change
without any maintenance, as it just reads the file mtime
Should fix #22
master
Daniel Berteaud 11 years ago
parent c86ac4e0d7
commit 6a916d7ba7
  1. 8
      public/vroom.pl
  2. 7
      templates/default/header.html.ep
  3. 14
      templates/default/js_include.html.ep

@ -15,6 +15,7 @@ use Digest::MD5 qw(md5_hex);
use MIME::Base64; use MIME::Base64;
use Email::Sender::Transport::Sendmail; use Email::Sender::Transport::Sendmail;
use Encode; use Encode;
use File::stat;
# Used to generate thanks on the about template # Used to generate thanks on the about template
our $components = { our $components = {
@ -229,6 +230,13 @@ helper get_random_name => sub {
return $name; return $name;
}; };
# return the mtime of a file
helper get_mtime => sub {
my $self = shift;
my ($file) = @_;
return stat($file)->mtime;
};
any '/' => 'index'; any '/' => 'index';
get '/about' => sub { get '/about' => sub {

@ -3,8 +3,11 @@
<head> <head>
<title><%= $title %></title> <title><%= $title %></title>
<meta name="viewport" content="width=device-width, initial-scale=1"/> <meta name="viewport" content="width=device-width, initial-scale=1"/>
<link href="/css/bootstrap.min.css" rel="stylesheet" type="text/css"> <%
<link href="/css/vroom.css" rel="stylesheet" type="text/css"> foreach my $css (qw(bootstrap.min.css vroom.css)){
%>
<link href="/css/<%= $css %>?<%= $self->get_mtime("css/$css") %>" rel="stylesheet" type="text/css">
<% } %>
<link rel="icon" type="image/png" href="/img/favicon.png" /> <link rel="icon" type="image/png" href="/img/favicon.png" />
</head> </head>
<body> <body>

@ -5,11 +5,9 @@
%> %>
var rootUrl = '<%= $url %>'; var rootUrl = '<%= $url %>';
</script> </script>
<script type="text/javascript" src="/js/simplewebrtc.bundle.js"></script> <% foreach my $js (qw(simplewebrtc.bundle.js jquery-1.11.1.min.js bootstrap.min.js
<script type="text/javascript" src="/js/jquery-1.11.1.min.js"></script> notify-combined.min.js jquery.browser.min.js sprintf.js
<script type="text/javascript" src="/js/bootstrap.min.js"></script> FileSaver.js vroom.js)){
<script type="text/javascript" src="/js/notify-combined.min.js"></script> %>
<script type="text/javascript" src="/js/jquery.browser.min.js"></script> <script type="text/javascript" src="/js/<%= $js %>?<%= $self->get_mtime("js/$js") %>"></script>
<script type="text/javascript" src="/js/sprintf.js"></script> <% } %>
<script type="text/javascript" src="/js/FileSaver.js"></script>
<script type="text/javascript" src="/js/vroom.js"></script>

Loading…
Cancel
Save