Search code examples
alfrescoalfresco-sharecmisopencmis

Client cache enabled but ignored on Alfresco


I'm looking at Alfresco's logs while fetching documents and I can see that each time I try to retrieve the same doc (same ID), a GET request is made to the remote repository.

I ran a test where I explicitly call session.getDefaultContext().setCacheEnabled(true) before calling session.getObject(id) several times. It seems the cache is ignored as the GET command is issued each time.

Do you think there may be other properties that should be set on the session that I'm missing? Or maybe some xml configuration for Alfresco?

Thanks


Solution

  • It depends on the document ID you are using to retrieve a document. Alfresco CMIS document IDs look like this (note the ";v.v" part):

    workspace://SpacesStore/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx;v.v
    

    Alfresco also accepts document IDs that look like node IDs (note the missing ";v.v" part) to retrieve documents, but always returns the format above.

    workspace://SpacesStore/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    

    The OpenCMIS cache uses the first document ID format (with ";v.v" part) as cache key. If you are using the second format, you will never get a cache hit and the client has to ask the repository again for the document data.