Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ELPP-2452 Added cache headers to recommendations #57

Merged
merged 6 commits into from Mar 30, 2017

Conversation

stephenwf
Copy link
Member

No description provided.

Copy link
Member

@thewilkybarkid thewilkybarkid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a test.

@stephenwf
Copy link
Member Author

Hi @thewilkybarkid we don't currently have a web test foundation set up for recommendations, would you like me to set that up for this? If so is there more test cases that you think should be covered?

@giorgiosironi
Copy link
Contributor

@stephenwf we will also have to add /ping soon if it's not already there, with "don't cache anything" headers

}

public function cache(Request $request, Response $response)
{
$response->setMaxAge($this->app['config']['ttl']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way to override this for particular responses? (will be needed in the future)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/ping has been added that does not use caching, make sure to merge develop in this branch to solve possible conflicts

@@ -430,7 +430,7 @@ public function handleException(Throwable $e): Response
return new JsonResponse(array_filter([
'error' => $e->getMessage(),
'trace' => $this->app['config']['debug'] ? $e->getTraceAsString() : null,
]), $e->getCode());
]), $e->getCode() ? $e->getCode() : 500);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$e->getCode() ?? Response::HTTP_INTERNAL_SERVER_ERROR?

@thewilkybarkid
Copy link
Member

We'll need a test for /ping.

@giorgiosironi
Copy link
Contributor

Now that web test cases seem well supported, I agree; there is a smoke test but it doesn't check caching headers.

$this->jsonRequest('GET', '/ping');
$response = $this->getResponse();
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals('max-age=300, must-revalidate, no-cache, no-store, public, stale-if-error=86400, stale-while-revalidate=300', $response->headers->get('Cache-Control'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I've added in a PrivateResponse class that bypasses the cache method completely.

@stephenwf stephenwf merged commit d032007 into elifesciences:develop Mar 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants