mirror of
https://github.com/LCPQ/QUESTDB_website.git
synced 2025-01-12 22:18:29 +01:00
Add header option and better use of max-age
This commit is contained in:
parent
ed21b74fc8
commit
de8648e5f1
@ -28,7 +28,7 @@ draft: false
|
|||||||
var key = ["file", "fileBase64"]
|
var key = ["file", "fileBase64"]
|
||||||
if (params.has(key[0])) {
|
if (params.has(key[0])) {
|
||||||
var filename = params.get(key[0]);
|
var filename = params.get(key[0]);
|
||||||
var text = await getTextFromFileUrlAsync(filename)
|
var text = await getTextFromFileUrlAsync(filename,{"Cache-Control":"max-age=0"})
|
||||||
$("#btn_download").click(function () {
|
$("#btn_download").click(function () {
|
||||||
var b = new Blob([text],{type:"text/plain;charset=utf-8"});
|
var b = new Blob([text],{type:"text/plain;charset=utf-8"});
|
||||||
saveAs(b, filename.substring(filename.lastIndexOf('/')+1))
|
saveAs(b, filename.substring(filename.lastIndexOf('/')+1))
|
||||||
|
@ -7,7 +7,8 @@ class Geometry {
|
|||||||
switch (trueTypeOf(file)) {
|
switch (trueTypeOf(file)) {
|
||||||
case String.name:
|
case String.name:
|
||||||
file = getFullDataPath("/structures/"+file)
|
file = getFullDataPath("/structures/"+file)
|
||||||
var str = await getTextFromFileUrlAsync(file)
|
const maxAge= (DebugMode.Enabled,0,600)
|
||||||
|
var str = await getTextFromFileUrlAsync(file,{"Cache-Control":`max-age=${maxAge}`})
|
||||||
break;
|
break;
|
||||||
case File.name:
|
case File.name:
|
||||||
var str = await getTextFromUploadedFileAsync(file)
|
var str = await getTextFromUploadedFileAsync(file)
|
||||||
|
@ -278,7 +278,8 @@ class dataFileBase {
|
|||||||
switch (trueTypeOf(file)) {
|
switch (trueTypeOf(file)) {
|
||||||
case String.name:
|
case String.name:
|
||||||
file = getFullDataPath(file)
|
file = getFullDataPath(file)
|
||||||
var str = await getTextFromFileUrlAsync(file)
|
const maxAge= (DebugMode.Enabled,0,600)
|
||||||
|
var str = await getTextFromFileUrlAsync(file,{"Cache-Control":`max-age=${maxAge}`})
|
||||||
break;
|
break;
|
||||||
case File.name:
|
case File.name:
|
||||||
var str = await getTextFromUploadedFileAsync(file)
|
var str = await getTextFromUploadedFileAsync(file)
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
async function getTextFromFileUrlAsync(url) {
|
async function getTextFromFileUrlAsync(url,header={}) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
var req = new XMLHttpRequest();
|
var req = new XMLHttpRequest();
|
||||||
req.open("GET",url, true);
|
req.open("GET",url, true);
|
||||||
req.setRequestHeader("Cache-Control", "max-age=0")
|
for (const [key, val] of Object.entries(header)) {
|
||||||
|
req.setRequestHeader(key,val)
|
||||||
|
}
|
||||||
req.onreadystatechange = function() {
|
req.onreadystatechange = function() {
|
||||||
if (req.readyState == 4) {
|
if (req.readyState == 4) {
|
||||||
if (req.status == 200 || req.status==304) {//when a good response is given do this
|
if (req.status == 200 || req.status==304) {//when a good response is given do this
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
class indexDB {
|
class indexDB {
|
||||||
static async loadAsync() {
|
static async loadAsync() {
|
||||||
var db = new indexDB
|
var db = new indexDB
|
||||||
const text = await getTextFromFileUrlAsync("/data/index.yaml")
|
const maxAge= (DebugMode.Enabled,0,600)
|
||||||
|
const text = await getTextFromFileUrlAsync("/data/index.yaml",{"Cache-Control":`max-age=${maxAge}`})
|
||||||
const myYaml = jsyaml.load(text);
|
const myYaml = jsyaml.load(text);
|
||||||
db.sets = ((myYaml.sets === null) ? new Map() : new Map(Object.entries(myYaml.sets)));
|
db.sets = ((myYaml.sets === null) ? new Map() : new Map(Object.entries(myYaml.sets)));
|
||||||
db.others = ((myYaml.others === null) ? [] : Array.from(myYaml.others));
|
db.others = ((myYaml.others === null) ? [] : Array.from(myYaml.others));
|
||||||
|
Loading…
Reference in New Issue
Block a user