Many sites (like TheServerSide) dynamically publish data that actually is not modified very often. In contrast, a new article on javaworld.com shows how to implement an event-driven publishing approach allowing you to serve static content that is kept in sync with back-end data. Who needs entity bean caching when you can just have Apache serve HTML?
This is an idea that I had wanted to implement years back when writing TSS, but couldn't figure out exactly how. :) What do you guys think about the proposed approach in the article?
Check out Publish event-driven Web content with JSP custom tags
Its a great idea, but like any idea, should be used with intelligence. Off the top of my head I would have 2 considerations. The article did not seem to address the synch problem. In the case where you have multiple events changing the same static page and multiple requests trying to read the page at the same time. The last time I looked, the IO classes do not handle this problem. The other consideration is when you have a kagillion static pages. Can the file system serve them up quick enough? I suppose both my considerations could be handled by using a database to store the static pages.
What is the difference between a file-system and a database? Not much, if you care to look.
key = filename, data-field = file-contents
File-system access = in-process, database-access = out-of-process.
A good filesystem has caching and "indexing" too.
<soapbox>try the open-source xfs file-system from sgi, it rocks</soapbox>
A database engine is a useful tool when you need its capabilities, but it is not a magic "solve-it-all" (unless you learned to program around 1990)
I don't like it. For a start he uses a JSP as the means to implement it in his example. This simply will not work in a web farm with multiple web servers.
Also his 'event driven' model is simply a poor mans content management system. i.e. all sorts of content being published for all sorts of reasons. Now the design of content management systems is way more complex. You have security, timeliness, duration, versioning and so on all creeping in.
Also his static/dynamic thingy is kinda like an inverse cache. Why not just implement a decent get last modified function and let the web proxies and caches (all the way to the users PC) serve up content as fast as possible.
How do you know if it has been modified unless you generate it?
To publish dynamic web contents at weak frequency, I used the following components : An ant-based daemon checks for new content delivered through various protocols (FTP, WebDAV, SMTP...) to produce XML files. These data and XSLT rendering stylesheets are referenced by specific tags comparing request time and 'last modified time' to produce and serve in-memory HTML sniplets in combination with HTTP parameters. Very simple solution for very simple requirements...
<What is the difference between a file-system and a database? Not much, if you care to look.>
You've got to be kidding. Right? There is a tremendous difference between what you can do with a file system and a database.
Your snide remarks about learning to program around 1990 and databases being a magic solve-it-all betray your poor attitude. There is nothing in the original reply that indicated that database was the best solution nor that it is the only solution. Those are entirely your own projections. It very well may be that something like xfs from sgi is the best solution. A simple reply stating that a database may be overkill and xfs might be better would suffice. Leave your poor attitude out of it.
Sorry if you were offended, Greg, but the worry was something about speed which might be alleviated by using a database.
I happen to work with a lot of people who started programming in the late eighties and early nineties, they believe databases are magical.I learned before that and know there are more ways to skin a cat, and lot less necessity for a RDBMS than salesmen want us to believe.
And my comment still is quite true. A database is a collection of data. Nothing more. Then there are tools like RDBMS to help you manage data, very good tools with lots of nice features. But they sit on the filesystem and are a separate process so they are not faster.
We are using this pattern for a while with cache tag from
We are linking cache time-to-live with last-modified date
of content file (there is such tag’s attribute). Works fine and is very easy/understandable.
By the way, in ASP.NET projects we’ve used an appropriate control with the same idea (cache keeping time has been linked to file modification date).