-
Notifications
You must be signed in to change notification settings - Fork 86
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
Persistent caching of HTTP responses fails due to presence of non-serializable classes #137
Comments
Play-WS does not assume that you want to use Java serialization as your persistence mechanism. In fact, persistence isn't handled through Play-WS -- that's abstracted out to the HTTP cache trait, which is responsible for serialization: So the problem here is that the ehcache cache has overflow to disk set to true: Instead, you can configure ehcache as follows: https://playframework.com/documentation/2.6.x/WsCache
|
Thanks for the explanation. Could you consider it as a feature request or is it completely out of the scope of Play-WS? I am willing to participate in implementing this if needed. The use case is as follows: we want to use long-term on-disk HTTP cache, adhering to RFC 5861, 7232 and 7234, which would allow our application to reuse it after the application restarts. Do you think it is feasible without (Java) serializability of responses? |
Oh, it's totally feasible. It's not something I can do myself at this point, but it's an option -- that being said, the assumption right now is that the cache is in-memory and synchronous. You can see in the README there's an example of Caffeine being used: https://github.com/playframework/play-ws#caching One thing that would have to be added is that Cache would have to implement Future[T] so that you could have IO thread handling behind an asynchronous boundary: #133 For serialization, I'd probably use Kryo with Chill and |
It'd be best if you could do it as an sbt subproject with a dependency on the AHC implementation. I didn't do any work to break out the cache implementation or API from AHC itself, so that's another possibility. |
Thanks for advice Will! I'll definitely consider the options you've mentioned. Closing. Cheers, Grigoriy. |
Play WS Version (2.5.x / etc)
1.0.0-M10
API (Scala / Java / Neither / Both)
Scala
Operating System (Ubuntu 15.10 / MacOS 10.10 / Windows 10)
Arch Linux (4.10.11-1-ARCH)
JDK (Oracle 1.8.0_72, OpenJDK 1.8.x, Azul Zing)
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
Library Dependencies
"org.ehcache" % "ehcache" % "3.3.1"
Expected Behavior
Please describe the expected behavior of the issue, starting from the first action.
Actual Behavior
Reproducible Test Case
https://github.com/grigoriy/play-ws-persistent-cache-bug
Notes
The problem is with CacheableHttpResponseStatus and CacheableHttpResponseBodyPart which are not serializable.
The text was updated successfully, but these errors were encountered: