组合多个CSS文件 [英] Combining multiple CSS files

查看:104
本文介绍了组合多个CSS文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我使用PHP脚本将多个CSS文件合并到一个脚本中,然后使用text / css的内容类型输出它们。

Right now I use a PHP script to pull together multiple CSS files into one script and then output them with a content-type of text/css.

这里的问题是浏览器不会缓存文件。

The problem them with this is the browser wont cache the file.

有更好的办法

感谢

推荐答案

通过PHP,你可以强制一个缓存头被发出,所以浏览器可以缓存输出,如果它需要:

If you have to serve the CSS via PHP, you can force a cache header to be emitted, so the browser can cache the output if it so desires:

<?php

    header('Cache-control: max-age=3600'); // cache for at least 1 hour
    header('Content-type: text/css');

    readfile('css1.css');
    readfile('css2.css');
    etc...

这篇关于组合多个CSS文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆