我正在尝试使用 Reducisaurus Web Service缩小 CSS 和 Javascript 但我遇到了问题...
假设我有两个未缩小的 CSS:
http:/domain.com/dynamic/styles/theme.php?color=red
http:/domain.com/dynamic/styles/typography.php?font=Arial
根据文档,我应该这样调用网络服务:
http:/reducisaurus.appspot.com/css?url=http:/domain.com/dynamic/styles/theme.php?color=red
如果我想同时缩小两个 CSS 文件:
http:/reducisaurus.appspot.com/css?url1=http:/domain.com/dynamic/styles/theme.php?color=red&url2=http:/domain.com/dynamic/styles/theme.php?color=red
如果我想为缓存指定不同的秒数(例如 3600),我会使用:
http:/reducisaurus.appspot.com/css?url=http:/domain.com/dynamic/styles/theme.php?color=red&expire_urls=3600
再次针对两个 CSS 文件:
http:/reducisaurus.appspot.com/css?url1=http:/domain.com/dynamic/styles/theme.php?color=red&url2=http:/domain.com/dynamic/styles/theme.php?color=red&expire_urls=3600
现在我的问题是,Reducisaurus 如何知道如何分隔我想要的 URL?它怎么知道 &expire_urls=3600
不是 my URL 的一部分?它怎么知道 &url2=...
不是 url1
的 GET 参数?我这样做对吗?我需要 urlencode
我的 URL 吗?
我看了看源代码,虽然我的 Java 很差,但似乎 methods acquireFromRemoteUrl()
and getSortedParameterNames()
from the BaseServlet.java file保存我的问题的答案 - 如果 GET 参数名称包含 -
或 _
它们应该被忽略?!
多个 &url(n)
怎么样?
最佳答案
是的,您需要先对 URL 进行 URL 编码,然后再将它们作为参数提交给另一个网络服务。
例如
http://google.com
成为
http%3A%2F%2Fgoogle.com
如果您这样做,像 ?、&、= 等特殊字符将不会在可能混淆 Web 服务的过程中幸存下来。
(不太确定您的第二个问题在问什么,抱歉。)
关于php - 构建 Reducisaurus URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2763761/