Skip to content

Commit

Permalink
Add cache control to getTile and downloadImage (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarciabriseno authored Mar 14, 2024
1 parent f44c7c8 commit 00b07c0
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/Module/WebClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ public function getJP2Header() {
}

/**
* Returns a full jpeg2000 image as a tif
* Returns a full jpeg2000 image converted to the designated image type (png/jpg/webp)
* extension is validated via the input validator.
*/
public function downloadImage() {
include_once HV_ROOT_DIR.'/../src/Database/ImgIndex.php';
Expand Down Expand Up @@ -244,6 +245,10 @@ public function downloadImage() {
$image['sunCenterOffsetParams']
);

// downloadImage requests are very deterministic, so make sure the client knows these are safe to cache.
// 30days (60sec * 60min * 24hours * 30days)
header("Cache-Control: max-age=2592000");

// Save and display
$tile->save();
$tile->display();
Expand Down Expand Up @@ -398,6 +403,10 @@ public function getTile() {
$image['sunCenterOffsetParams']
);

// getTile requests are very deterministic, so make sure the client knows these are safe to cache.
// 30days (60sec * 60min * 24hours * 30days)
header("Cache-Control: max-age=2592000");

// Save and display
$tile->save();
$tile->display();
Expand Down Expand Up @@ -1141,7 +1150,7 @@ public function getRandomSeed() {
// Output result
$this->_printJSON(json_encode($response));
}

/**
* Returns an embeddable image showing LASCO C2/C3 data leading up to
* the selected eclipse.
Expand Down Expand Up @@ -1177,7 +1186,7 @@ public function getEclipseImage() {
// Create the base screenshot image
include_once HV_ROOT_DIR.'/../src/Image/Composite/HelioviewerScreenshot.php';
$screenshot = new Image_Composite_HelioviewerScreenshot(
$layers, $events, false, false, $celestialBodies, false, 'earth', 0, 0, $now_str, $roi,
$layers, $events, false, false, $celestialBodies, false, 'earth', 0, 0, $now_str, $roi,
['grayscale' => true, 'eclipse' => true, 'moon' => $this->_options['moon']]
);
$screenshot->display();
Expand Down

0 comments on commit 00b07c0

Please sign in to comment.