////
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
////

== block

=== Description

Renders a block of markup and caches the result so that the next time the same
block is rendered it doesn't have to be evaluated again.  Optionally, a key may
be provided which can be helpful if the cached content is different per user,
for example.

Note that the key's namespace is confined to this particular cached block.  This
means that if there are 2 separate blocks which share the same key value, the 2
will not collide with each other.  Each cached block has its own set of keys.

=== Examples


[source,xml]
----
<cache:block>
    <!-- Any valid markup may be included here, including dynamic expressions, invoking other tags, etc.... -->
</cache:block>
----

[source,xml]
----
<cache:block key="${currentUser.id}">
    <!-- Any valid markup may be included here, including dynamic expressions, invoking other tags, etc.... -->
</cache:block>
----

[source,xml]
----
<cache:block key="${currentUser.id}" ttl="${60*60*24*7}">
    <!-- Any valid markup may be included here, including dynamic expressions, invoking other tags, etc.... -->
</cache:block>
----

=== Attributes

* `key` (optional) - An optional key that may be provided to allow for different instances of the block to be held in the cache, presumably with different content.
* `ttl` (optional) - An optional ttl (seconds) may be provided to allow the blocks to automatically evict a specified number of seconds after first insertion.
