Skip to content

Commit

Permalink
make loading of lists (SPARQL query) asynchronous
Browse files Browse the repository at this point in the history
Not a real solution for #20 but at least is looks faster in the GUI (because loading isn't blocking)
  • Loading branch information
coret committed Dec 22, 2023
1 parent 9964b72 commit b7c973f
Show file tree
Hide file tree
Showing 2 changed files with 251 additions and 207 deletions.
26 changes: 26 additions & 0 deletions web/get-list.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

include("includes/search.php");

if (isset($_GET["list"])) {
if ($_GET["list"]=="publishers") {
$list=getPublishers();
} elseif ($_GET["list"]=="creators") {
$list=getCreators();
} elseif ($_GET["list"]=="formats") {
$list=getFormats();
} else {
exit;
}

# client cache 2 hours
$now = time();
$generatedAt = gmdate('D, d M Y H:i:s T', $now);
$lastModified = gmdate('D, d M Y 00:00:00 T', $now);
$expiresAt = gmdate('D, d M Y H:i:s T', strtotime($lastModified) + 2*3600); # 2 hours
header('Last-modified: ' . $lastModified);
header('Cache-control: max-age=' . strtotime($expiresAt) - strtotime($generatedAt));

header('Content-Type: application/json; charset=utf-8');
echo json_encode($list);
}
Loading

0 comments on commit b7c973f

Please sign in to comment.