+  HandyCache форум
|-+  Главная категория» English forum» How to load/redirect all jQuery to google CDN
Имя пользователя:
Пароль:
Страниц: [1]   Вниз
  Отправить эту тему    Печать  
Автор Тема: How to load/redirect all jQuery to google CDN  (Прочитано 7539 раз)
0 Пользователей и 1 Гость смотрят эту тему.
takien
Новичок
*

Репутация: +0/-0
Offline Offline

Сообщений: 7


WWW
« : 01 декабря 2011, 06:38:18 »

Hello,
there's many sites using jQuery, for example in WordPress powered sites,

http://example.com/wp-includes/js/jquery/jquery.js?ver=1.6.1

I want ALL URL like that should be redirected to

http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js 

No matter from what domain, so if i visit new wordpress site, it wont download jQuery again, (only load from google apis that already saved to cache).

1.6.1 indicates jquery version.

I have tried redirect and or URL transforming but no luck.

Here is my rule in URL transforming.

#5#~#True#~#jquery\.js\?ver=)(\.\d+)#~#ajax.googleapis.com/ajax/libs/jquery/\2/jquery.min.js#~#True#~#True

Thank you for your help.
Сообщить модератору   Записан
mai62
Автор HC
*****

Репутация: +226/-4
Offline Offline

Сообщений: 6383


« Ответ #1 : 01 декабря 2011, 12:39:22 »

Try this rule
#5#~#True#~#(.*)(/jquery/[\d.]+/)(.*)#~#libs\2\3#~#False#~#True
Сообщить модератору   Записан
DenZzz
Модератор
*****

Репутация: +179/-11
Offline Offline

Сообщений: 5589



« Ответ #2 : 01 декабря 2011, 14:11:11 »

No. It's a wrong rule. Try this:

#5#~#True#~#.*/jquery\.js\?ver=([\d.]+)$#~#ajax.googleapis.com/ajax/libs/jquery/\1/jquery.min.js#~#False#~#True
« Последнее редактирование: 01 декабря 2011, 14:16:03 от DenZzz » Сообщить модератору   Записан
takien
Новичок
*

Репутация: +0/-0
Offline Offline

Сообщений: 7


WWW
« Ответ #3 : 01 декабря 2011, 17:56:59 »

Try this rule
#5#~#True#~#(.*)(/jquery/[\d.]+/)(.*)#~#libs\2\3#~#False#~#True

No. It's a wrong rule. Try this:

#5#~#True#~#.*/jquery\.js\?ver=([\d.]+)$#~#ajax.googleapis.com/ajax/libs/jquery/\1/jquery.min.js#~#False#~#True

thanks Улыбка
DenZzz solution is almost there.. with little edit.
add \ backslash before dot in [\d\.] and add http://

#5#~#True#~#.*/jquery\.js\?ver=([\d\.]+)$#~#http://ajax.googleapis.com/ajax/libs/jquery/\1/jquery.min.js#~#True#~#True

thank you very much, if i got rules for other jquery url format, or other js library (jqueryui etc), I will post here. Улыбка

note: this works in redirect, not url transforming.
Posted on: 01 December 2011, 16:57:43

Ask again: Веселый

site hosted WordPress.com has URL like this
Код:
http://s1.wp.com/wp-includes/js/jquery/jquery.js?m=1322588680g&&ver=1.7.1

how to strip m=1322588680g&

This regex does not work:
.*/jquery\.js\?([a-z0-9=;\&\#]+)?ver=([\d\.]+)$

rule format:
Код:
#5#~#True#~#.*/jquery\.js\?([a-z0-9=;\&\#]+)?ver=([\d\.]+)$#~#http://ajax.googleapis.com/ajax/libs/jquery/\2/jquery.min.js#~#True#~#True


Whereas the practice says no error in that expression:

Код:
0(1): http://s1.wp.com/wp-includes/js/jquery/jquery.js?m=1322588680g&ver=1.7.1
1(50): m=1322588680g&
2(73): 1.7.1
--------- After -- replacement ----------
Mark:
Сообщить модератору   Записан
DenZzz
Модератор
*****

Репутация: +179/-11
Offline Offline

Сообщений: 5589



« Ответ #4 : 01 декабря 2011, 22:51:54 »

DenZzz solution is almost there.. with little edit.
add \ backslash before dot in [\d\.]

It's not necessary inside the square brackets [...] (according to the syntax of regular expressions).

Цитировать
and add http://

That's correct only for Redirect list, but there is no need for URL transforming list.



Try this:

#5#~#True#~#.*/jquery\.js\?(.*&)?ver=([\d.]+).*#~#http://ajax.googleapis.com/ajax/libs/jquery/\2/jquery.min.js#~#False#~#True



Цитировать
site hosted WordPress.com has URL like this
Код:
http://s1.wp.com/wp-includes/js/jquery/jquery.js?m=1322588680g&&ver=1.7.1

It's a wrong URL. Fragment from # and further can not be sent to the proxy (according to the Hypertext Transfer Protocol). Look at the HandyCache Monitor.
« Последнее редактирование: 01 декабря 2011, 23:02:27 от DenZzz » Сообщить модератору   Записан
takien
Новичок
*

Репутация: +0/-0
Offline Offline

Сообщений: 7


WWW
« Ответ #5 : 03 декабря 2011, 14:53:01 »

It's not necessary inside the square brackets [...] (according to the syntax of regular expressions).

That's correct only for Redirect list, but there is no need for URL transforming list.



Try this:

#5#~#True#~#.*/jquery\.js\?(.*&)?ver=([\d.]+).*#~#http://ajax.googleapis.com/ajax/libs/jquery/\2/jquery.min.js#~#False#~#True



It's a wrong URL. Fragment from # and further can not be sent to the proxy (according to the Hypertext Transfer Protocol). Look at the HandyCache Monitor.


thanks, but it still not work.
in the monitor, the url is truncated like this:
Код:
http://s1.wp.com/wp-includes/js/jquery/jquery.js?m=1322588681g&
Сообщить модератору   Записан
www
Новичок
*

Репутация: +5/-0
Offline Offline

Сообщений: 39


« Ответ #6 : 20 декабря 2011, 10:19:06 »

I use these rules to redirect scripts already hosted by Google to their lastest version:

Код:
#5#~#True#~#(googleapis\.com\/ajax\/libs\/mootools)\/(?!1\.4\.1).*\/(mootools-yui-compressed\.js)#~#$1/1.4.1/$2#~#False#~#True

#5#~#True#~#(googleapis\.com\/ajax\/libs\/jquery)\/(?!1\.7\.1).*\/(jquery\.min\.js)#~#$1/1.7.1/$2#~#False#~#True

#5#~#True#~#(googleapis\.com\/ajax\/libs\/jqueryui)\/(?!1\.8\.16).*\/(jquery-ui\.min\.js)#~#$1/1.8.16/$2#~#False#~#True

#5#~#True#~#(googleapis\.com\/ajax\/libs\/prototype)\/(?!1\.7\.0\.0).*\/(prototype\.js)#~#$1/1.7.0.0/$2#~#False#~#True
Сообщить модератору   Записан
Страниц: [1]   Вверх
  Отправить эту тему    Печать  

 
Перейти в: