Closed davidyuk closed 2 years ago
@davidyuk what's the reason for caching the compile output? I don't understand that 🤔
actually I dislike this route. we still want to avoid calling the http compiler on aepp / backend initialization via source code. that's what https://github.com/aeternity/aepp-sdk-js/issues/1681 is about mainly. once a contract is deployed we could and should 100% rely on the ACI only.
I can't believe we still discuss this 😢
if we speak about "on-demand" compilation by e.g. AEstudio the caching won't help anyway because source-code changes too frequently. there we discussed that we'd like to revisit using erlscripten to remove the heavy dependency to the http compiler
I absolutely agree with @marc0olo the public HTTP compiler should be depreciated and there is no any other sensible use-case of it than online editors (i.e. contracts app, aestudio) which should use their own versions (CORS protected).
To sumarize this once again, apps should compile during development and package their ACI's for runtime usages (calldata).
@marc0olo this was intended as a workaround for existing apps to don't have to make urgent changes in sdk, but anyway, HTTP is not working this way
I'm trying to enable caching of compiler responses as I'm proposed in https://github.com/aeternity/aepp-sdk-js/issues/1681#issuecomment-1289111343
Firstly I've added the "Cache-Control" header as middleware, but I found that POST requests can't be cached https://stackoverflow.com/a/626083/6176994. Later I new that GET requests don't support the request body in some environments (for example
fetch
in browser fails with "Request with GET/HEAD method cannot have body").The rest option is to encode parameters in query part of URL instead of request body, but URL length is limited in some environments https://stackoverflow.com/a/417184/6176994 It could work well in modern browsers the same way as data URLs, but it needs additional testing.
To use POST in compiler methods is not semantic because compiler doesn't have its own state, but there is no easy way to replace it.
A page for testing: