Created
June 27, 2018 16:07
-
-
Save willfrew/d0d0938bec20f81f1c3ab2b6b294b6e6 to your computer and use it in GitHub Desktop.
Iframe caching test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head></head> | |
<body> | |
<script> | |
(function() { | |
// 1 or 2 | |
let i = Math.round(Math.random()) + 1 | |
console.log(`Loading iframe ${i}`); | |
let iframe = document.createElement('iframe'); | |
iframe.src = `./iframe${i}.html`; | |
iframe.name = 'consistent'; | |
document.body.appendChild(iframe); | |
})(); | |
</script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script> | |
console.log('IFRAME 1'); | |
</script> | |
</head> | |
<body></body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script> | |
console.log('IFRAME 2'); | |
</script> | |
</head> | |
<body></body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "iframe-test", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"static-server": "^2.2.1" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var StaticServer = require('static-server'); | |
var server = new StaticServer({ | |
rootPath: '.', // required, the root of the server file tree | |
port: 1337, // required, the port to listen | |
cors: '*', // optional, defaults to undefined | |
}); | |
server.on('request', function (req, res) { | |
let cacheControl = (/host.html/.test(req.path)) | |
? 'no-cache, no-store, must-revalidate' | |
: 'public, max-age=31536000' | |
res.headers = { | |
...res.headers, | |
'Cache-Control': cacheControl, | |
}; | |
}); | |
server.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment