Work around AppCache issues to switch to SSL.

R=kasperl@google.com

Review URL: https://codereview.chromium.org//465903002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39127 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
ahe@google.com 2014-08-12 11:08:52 +00:00
parent 0584a86f99
commit e4810a41ff
7 changed files with 121 additions and 23 deletions

View file

@ -102,9 +102,39 @@ handlers:
upload: index.html
secure: always
# The nossl file below help work around bugs/features in interaction between
# AppEngine and AppCache. When a return user goes to http://try.dartlang.org/
# (no SSL), AppCache will serve index.html from cache, try to fetch the old
# manifest (nossl.appcache) and the files listed in the manifest. In additation
# the files listed in the manifest, it will also fetch index.html, as it is the
# master. However, we want index.html to be redirected to the SSL version, and
# AppCache sees this redirection as a network error. When an error occurs,
# AppCache will keep serving the old page. So we configure nossl.appcache to
# provide fallbacks for index.html and leap.dart.js. The fallback for
# leap.dart.js is nossl.js which will take care of redirecting to
# https://try.dartlang.org/ (with SSL) using JavaScript. Unfortunately, Chrome
# seems to keep the old version of index.html cached indefinitely. The only way
# to avoid that appears to serve up a different index.html depending on if it
# is a secure connection or not. This would require a Python script, and
# something we may consider implementing in the future.
- url: /nossl.appcache
static_files: nossl.appcache
upload: nossl.appcache
secure: optional
- url: /nossl.js
static_files: nossl.js
upload: nossl.js
secure: optional
- url: /nossl.html
static_files: nossl.html
upload: nossl.html
secure: optional
- url: /ssl.appcache
static_files: ssl.appcache
upload: ssl.appcache
secure: always
- url: /(.*\.(html|js|png|css|dart|json))
@ -117,11 +147,6 @@ handlers:
upload: fontawesome-webfont.woff
secure: always
- url: .*
static_files: not_found.html
upload: not_found.html
secure: always
libraries:
- name: webapp2
version: "2.5.2"

View file

@ -150,7 +150,8 @@
'inputs': [
'add_time_stamp.py',
'nossl.appcache',
'<@(try_dart_static_files)',
'nossl.js',
'nossl.html',
'build_try.gyp', # If the list of files changed.
],
'outputs': [
@ -165,6 +166,27 @@
'<(SHARED_INTERMEDIATE_DIR)/nossl.appcache',
],
},
{
'action_name': 'ssl_appcache',
'message': 'Creating ssl.appcache',
'inputs': [
'add_time_stamp.py',
'ssl.appcache',
'<@(try_dart_static_files)',
'build_try.gyp', # If the list of files changed.
],
'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/ssl.appcache',
],
# Try Dart! uses AppCache. Cached files are only validated when the
# manifest changes (not its timestamp, but its actual contents).
'action': [
'python',
'add_time_stamp.py',
'ssl.appcache',
'<(SHARED_INTERMEDIATE_DIR)/ssl.appcache',
],
},
{
'action_name': 'make_pkg_packages',
'inputs': [
@ -193,6 +215,9 @@
'app.yaml',
'<@(try_dart_static_files)',
'<(SHARED_INTERMEDIATE_DIR)/nossl.appcache',
'<(SHARED_INTERMEDIATE_DIR)/ssl.appcache',
'nossl.js',
'nossl.html',
],
},
],

View file

@ -4,7 +4,7 @@ Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
for details. All rights reserved. Use of this source code is governed by a
BSD-style license that can be found in the LICENSE file.
-->
<html lang="en" manifest="nossl.appcache" itemscope itemtype="http://schema.org/Product">
<html lang="en" manifest="ssl.appcache" itemscope itemtype="http://schema.org/Product">
<head>
<meta charset="utf-8">
<title>Try Dart!</title>

View file

@ -5,19 +5,6 @@ CACHE MANIFEST
# @@TIMESTAMP@@
CACHE:
index.html
dartlang-style.css
line_numbers.css
leap.dart.js
iframe.html
iframe.js
dart-icon.png
dart-iphone5.png
sdk.json
/css/fonts/fontawesome-webfont.woff?v=3.0.1
NETWORK:
*
FALLBACK:
/leap.dart.js /nossl.js
/ /nossl.html

16
site/try/nossl.html Normal file
View file

@ -0,0 +1,16 @@
<!DOCTYPE html>
<!--
Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
for details. All rights reserved. Use of this source code is governed by a
BSD-style license that can be found in the LICENSE file.
-->
<html lang="en">
<head>
<meta charset="utf-8">
<title>Page has moved.</title>
<meta http-equiv="refresh" content="0;URL='https://try.dartlang.org/'" />
</head>
<body>
<p>This page has moved to <a href="https://try.dartlang.org/">https://try.dartlang.org/</a></p>
</body>
</html>

19
site/try/nossl.js Normal file
View file

@ -0,0 +1,19 @@
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
try {
document.location = 'https://try.dartlang.org/';
} catch (e) {
// Ignored.
}
document.documentElement.innerHTML = (
'<head>' +
'<meta charset="utf-8">' +
'<meta http-equiv="refresh" content="0;URL=\'https://try.dartlang.org/\'" />' +
'<title>Redirecting</title>' +
'</head>' +
'<body>' +
'<p>This page has moved to <a href="https://try.dartlang.org/">https://try.dartlang.org/</a>.</p>' +
'</body>');

26
site/try/ssl.appcache Normal file
View file

@ -0,0 +1,26 @@
CACHE MANIFEST
# Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
# @@TIMESTAMP@@
CACHE:
compiler_isolate.dart.js
dartlang-style.css
iframe.html
iframe.js
leap.dart.js
line_numbers.css
sdk.json
dart-icon-196px.png
dart-icon.png
dart-iphone5.png
favicon.ico
try-dart-screenshot.png
/css/fonts/fontawesome-webfont.woff?v=3.0.1
NETWORK:
*