The assumptions that I have are –
- Representations have a definition which have its last modified date. E.g., Script that generates a JSON representation of a resource has when the script has been last modified.
- Resource’s persistent storage does not have any storage limitation
Now the situation is that I have Resources for which their representations could be either pre-generated or generated on the fly; where pre-generated refers to text/html or application/atom+xml being generated when the resource is modified (could be done asynchronously) and generated on the fly refers to, e.g., a JSP/PHP script generating representation when requested.
What I am confused about is how much performance increment would pre-generation be versus generated-on-fly + caching? What are your experience/opinion?
You ask about performance, but don’t indicate what should perform, so I’m assuming that the metric is “response time”.
The two approaches are just variants of each other. Pre generation is merely a different way of caching. So practically, the only difference is that one is “lazy” whereas the other isn’t.
So the difference in latency would be zero when all resources have been cached (and don’t change). But the performance difference varies according to several parameters:
A tipping point is if an item is modified less often that it is accessed.
But there are a lot of other factors to consider: