开发者

JSP and dynamically aggregated css

Is there a better way to aggregate several css files ( based on what a give page requires ) than including them in a jsp file with c:if tags?

The top of the file (sitting outside of web-inf dir, alongside images files and such)

<%@ taglib pr开发者_如何学编程efix="c" uri="http://java.sun.com/jsp/jstl/core" %>

... followed by <%@include file="some.css" %> as needed. It works, it's simple, I'm just wondering if it could be done better.


If you were kind, your CSS request would follow some kind of aggregation pattern.

<link rel="stylesheet" type="text/css" href="core.css?part1&part2&part3">

And then, your result would be kind enough to set the caching headers properly, the ETag, and honor the "If-Modified-Since" header (perhaps based on the latest change date of the files you decide to include).


Is there any reason why you can't just include the CSS pages with normal HTML links, so that they can be cached?

<link rel="stylesheet" href="some.css" type="text/css" media="screen" />
<link rel="stylesheet" href="some2.css" type="text/css" media="screen" />

That way the browser can cache the file, and requests will only be made once for all the pages that use it. Then you could just have each page specify the links that it needs.


How about

<link rel="stylesheet" type="text/css" href="${pageSpecificCssFileName}.css">

wherein you define ${pageSpecificCssFileName} in page controller?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜