Comments (5)
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
<ehcache
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
name="play-ws-cache"
updateCheck="false"
>
<cache name="play-ws-cache" maxEntriesLocalHeap="10000" eternal="false"
timeToIdleSeconds="360" timeToLiveSeconds="1000" overflowToDisk="false" />
</ehcache>
from play-ws.
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?
from play-ws.
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 setRegistrationRequired
: https://github.com/twitter/chill / https://github.com/EsotericSoftware/kryo#registration as it'd be faster and inline with the JVM. If you're looking for a shared cache between programs, then personally I think Avro is the best overall choice.
from play-ws.
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.
from play-ws.
Thanks for advice Will! I'll definitely consider the options you've mentioned. Closing. Cheers, Grigoriy.
from play-ws.
Related Issues (20)
- Incorrect reflection-config.json for shaded-asynchttpclient?
- Rename `master` branch to `main` HOT 1
- Add Scala 3 support HOT 10
- Add Sonatype-based publishing HOT 8
- Remove line
- Can't use 2.1.4 with Java 8 HOT 4
- IOException Connection closed after many requests
- Source code for shaded jars are not properly published along with the shaded jars
- Upgrade scala-xml for Scala 2.13 to 2.x releases
- Null pointer error in `play.api.libs.ws.ahc.CookieBuilder` if cookie has no value
- [feature] Add support for `SameSite` attribute in `WSCookie`
- Got "Digest algorithm not supported: md5" on try use DIGEST
- I need to use the GMSSL protocol HOT 1
- StandaloneAhcWSRequest rewrites application/x-www-form-urlencoded requests body, changes ordering of keys HOT 1
- scala StandaloneWSRequest.stream() buffers entire response in memory HOT 1
- Binary incompatibility between v2.1.11 and v2.2.x due to AhcWSClientConfig HOT 2
- StandaloneAhcWSRequest java.lang.OutOfMemoryError: Java heap space HOT 1
- Inconsistent shading of asynchttpclient HOT 5
- akka.util.ByteString in pekko application HOT 13
- Streamed response headers are case sensitive HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from play-ws.