The data the server sends contain information about whether or not the data is cacheable.
If the data is cacheable, it might contain some sort of a version number. The version number is what makes caching possible: since the client knows which version of the data it already has (from a previous response), the client can avoid requesting the same data again and again.
The client should also be aware if the current version of the data is valid or expired, in which case the it will know that it has to send another request to the server to get the most updated data about the state of a resource.
This constraint is optional. An API can be RESTful even without providing code on demand.
A client can request code from the server. The response usually in the form of a script, will contain some code.