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

EZP-20172: Location based HTTP cache aware REST API #659

Merged
merged 2 commits into from Jan 20, 2014

Conversation

@bdunogier
Copy link
Member

commented Dec 13, 2013

See http://jira.ez.no/browse/EZP-20172.

The current goal is to implement TTL & purge based cache on applicable REST resources.

Cached resources

The following resources are now cached by the reverse proxy, with TTL and a X-Location-ID header. They use the same settings than location view: content.view_cache, content.ttl_cache and content.default_ttl:

  • GET /content/objects/{contentId}
  • GET /content/objects/{contentId}/locations
  • GET /content/objects/{contentId}/versions
  • GET /content/objects/{contentId}/versions/{versionNumber}
  • GET /content/objects/{contentId}/versions/{versionNumber}/relations
  • GET /content/objects/{contentId}/versions/{versionNumber}/relations/{relationId}
  • GET /content/locations/{locationPath}
  • GET /content/locations/{locationPath}/children
  • GET /content/locations/{locationPath}/urlaliases
  • GET /user/groups/{groupPath}
  • GET /user/users/{userId}
  • GET /user/groups/{groupPath}/subgroups
  • GET /user/groups/{groupPath}/users
  • GET /content/binary/images/{imageId}/variations/{variationIdentifier}

Changes

  • Removed the need for QaFoo\RMF\Message by making Output\Visitor return an HttpFoundation\Response directly. The Response object is also used internally by the visitor, and can be manipulated directly from ValueObjectVisitor implementations.
  • Added a dedicated value object + visitor, CachedValue

Todo

  • Cache remaining applicable resources: root, binarycontent (?), user and group resources
  • Consider caching of redirection based resources, like /content/objects/{contentId}/currentversion
  • Refactor usage of X-User-Hash. It can be made more global, probably from the CachedValue visitor
  • Implement cache configuration injection into the CachedValue visitors (hardcoded in the service definition)
  • Consider making LocationCachedValue::$locationId nullable, and only set the header if not null. Would prevent having to check the location ID in every controller method.
  • See what can currently be done for resources that have nothing to do with locations. How would expiration work ? Is a TTL only based HTTP cache acceptable ?
@@ -43,7 +44,9 @@ public function addVisitor( $regexp, OutputVisitor $visitor )
* @param \Symfony\Component\HttpFoundation\Request $request
* @param mixed $result
*
* @return \eZ\Publish\Core\REST\Common\Message
* @throws NowViewFoundException

This comment has been minimized.

Copy link
@dpobel

dpobel Dec 13, 2013

Contributor

lol

This comment has been minimized.

Copy link
@bdunogier

bdunogier Dec 13, 2013

Author Member

+1

This comment has been minimized.

Copy link
@lolautruche

lolautruche Dec 13, 2013

Contributor

And it doesn't return anything any more ?

This comment has been minimized.

Copy link
@bdunogier

bdunogier Dec 18, 2013

Author Member

Hmm, it does, but it does have a return inside the loop.

@dpobel

This comment has been minimized.

Copy link
Contributor

commented Dec 16, 2013

seems OK to me, two small questions/remarks though:

  • why $_request instead of $request ?
  • some methods get the request as the last argument, some as the first one, I wonder how this can work and I would prefer a consistent choice
@bdunogier

This comment has been minimized.

Copy link
Member Author

commented Jan 6, 2014

@dpobel note that the arguments ordering works because symfony doesn't care in which order parameters are provided.

@dpobel

This comment has been minimized.

Copy link
Contributor

commented Jan 8, 2014

+1
I guess you'll create follow up stories for the remaining todo items ?

@lolautruche

This comment has been minimized.

Copy link
Contributor

commented Jan 14, 2014

+1

@andrerom

This comment has been minimized.

Copy link
Member

commented Jan 15, 2014

+1, but @dpobel 's question still stands ("I guess you'll create follow up stories for the remaining todo items ?")

@bdunogier

This comment has been minimized.

Copy link
Member Author

commented Jan 20, 2014

The TODO items based on location cache are all done.

I'll list the resources that are NOT cached (because location id doesn't apply) in a follow-up story.

bdunogier added 2 commits Dec 13, 2013
EZP-20172: Refactored object visiting
- Removed the need for QaFoo\RMF\Message by making Output\Visitor return
  an HttpFoundation\Response directly. The Response object is also used
  internally by the visitor, and can be manipulated directly from
  ValueObjectVisitor implementations.
EZP-20172: Cached REST resources on LocationId
GET /content/objects/{contentId}
GET /content/objects/{contentId}/locations
GET /content/objects/{contentId}/versions
GET /content/objects/{contentId}/versions/{versionNumber}
GET /content/objects/{contentId}/versions/{versionNumber}/relations
GET /content/objects/{contentId}/versions/{versionNumber}/relations/{relationId}
GET /content/locations/{locationPath}
GET /content/locations/{locationPath}/children
GET /content/locations/{locationPath}/urlaliases
GET /user/groups/{groupPath}
GET /user/users/{userId}
GET /user/groups/{groupPath}/subgroups
GET /user/groups/{groupPath}/users
GET /content/binary/images/{imageId}/variations/{variationIdentifier}
bdunogier added a commit that referenced this pull request Jan 20, 2014
Merge pull request #659 from ezsystems/implement/EZP-20172-REST_HTTP_…
…cache

EZP-20172: Location based HTTP cache aware REST API

@bdunogier bdunogier merged commit b221fd7 into master Jan 20, 2014

@bdunogier bdunogier deleted the implement/EZP-20172-REST_HTTP_cache branch Jan 20, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants
You can’t perform that action at this time.