Skip to content

Instantly share code, notes, and snippets.

@nathansmith
Last active December 15, 2015 11:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathansmith/5256203 to your computer and use it in GitHub Desktop.
Save nathansmith/5256203 to your computer and use it in GitHub Desktop.
Used to cache-bust <html manifest="..."> locally. Turns static when deployed.
# Used to cache-bust <html manifest="..."> locally
def manifest_time
t = Time.now
year = t.year
month = t.month
day = t.day
hour = t.hour
min = t.min
# Seconds changes too frequently for
# manifest, so HH:MM:00 or HH:MM:30.
sec = t.sec > 30 ? 0 : 30
# Outputs this format... 2013-03-27 12:11:00 UTC
return Time.utc(year, month, day, hour, min, sec)
end
CACHE MANIFEST
# LAST UPDATED: <%= manifest_time %>
#----------------------------------------------------------------------------------------------------
#
# INTERNET CONNECTION REQUIRED...
#
NETWORK:
../json
#----------------------------------------------------------------------------------------------------
#
# CACHE THESE FILES OFFLINE...
#
CACHE:
#
# CSS
#
../stylesheets/application.css
#
# JavaScript
#
../javascripts/jquery.js
../javascripts/application.js
#
# HTML
#
../whatever.html
#
# Images
#
../images/whatever.png
<!DOCTYPE html>
<html lang="en" manifest="./offline/manifest.appcache">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<title>
Manifest Example
</title>
<link rel="stylesheet" href="./stylesheets/application.css" />
</head>
<body>
<p>
Just an example.
</p>
<script src="./javascripts/application.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment