+  HandyCache форум
|-+  Главная категория» English forum» Extension script for Content delay
Имя пользователя:
Пароль:
Страниц: [1] 2  Все   Вниз
  Отправить эту тему    Печать  
Автор Тема: Extension script for Content delay  (Прочитано 17980 раз)
0 Пользователей и 1 Гость смотрят эту тему.
truefriend-cz
Постоялец
***

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

Сообщений: 118


« : 23 декабря 2012, 15:24:08 »

I can not create script for delay content by filetype.
Can someone help me with the creation of the script for delayed loading by file type from internet? The objective is to make this schema loading. Use is on a slow internet connection.


Browser -> Requested URL -> Extension for Content Delay

Extension for Content Delay in processing:

load htm|html|php|js|css|xy|.*
delay 1 sec
load bmp|jpg|jpeg|png|svgz|swf|tiff|wmf
delay 2 sec
load swf|asf|gif

To retrieve files from cache without this restrictions
« Последнее редактирование: 23 декабря 2012, 16:14:34 от truefriendcz » Сообщить модератору   Записан
truefriend-cz
Постоялец
***

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

Сообщений: 118


« Ответ #1 : 23 декабря 2012, 16:44:49 »

I created script
Код:
--[[ <HCExtension>
@name         Delay limit for filetype access by URL
@event         RequestHeaderReceived/Request
</HCExtension> ]]

function Request()
  re.match(hc.url, '\.(bmp|jpg|jpeg|png|svgz|swf|tiff|wmf)$')
  hc.sleep(10000)
end

but this solution block load complete page Грустный
Сообщить модератору   Записан
mirny
Пользователь
**

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

Сообщений: 84


« Ответ #2 : 23 декабря 2012, 17:02:32 »

I dunno how exactly such an extension can be made, but probably matching urls is not the best idea. I bet Content-Type field from response headers is what you're really interested in.
Добавлено: 23 Декабрь 2012, 16:55:41

Disregard this. You have to establish connection to get these in the first place. IDK.
Сообщить модератору   Записан
truefriend-cz
Постоялец
***

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

Сообщений: 118


« Ответ #3 : 23 декабря 2012, 18:22:08 »

I cant find Content-Type for Extensions.
Сообщить модератору   Записан
mirny
Пользователь
**

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

Сообщений: 84


« Ответ #4 : 24 декабря 2012, 04:40:09 »

That task is too hardcore for you then. Forget about it.
Сообщить модератору   Записан
truefriend-cz
Постоялец
***

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

Сообщений: 118


« Ответ #5 : 24 декабря 2012, 05:10:53 »

It is a problem because I do not know it. I'd formed the other scripts but I know everything now. Meanwhile, I teach at other finished scripts. Decrypts scripts and Russian language Улыбка On the filetype and sleep there but it is not much.
This function, I have tried to reach the router Mikrotik and there is something like a burst limit (speed limit on a time and a file type), but only from a higher to a lower speed which is not applicable in this case.
« Последнее редактирование: 24 декабря 2012, 05:47:08 от truefriendcz » Сообщить модератору   Записан
mirny
Пользователь
**

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

Сообщений: 84


« Ответ #6 : 24 декабря 2012, 05:34:24 »

I can't imagine a solution to your question without a shitload of complications. And you're probably trying to solve the wrong problem.

Try to limit the number of connections in your browser instead if your connection is slow. I set that number to 1 in firefox and the browser does the right thing by itself allowing me to use the cheapest mobile plan and not suffer from it.
Сообщить модератору   Записан
truefriend-cz
Постоялец
***

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

Сообщений: 118


« Ответ #7 : 24 декабря 2012, 05:55:25 »

Trying to solve unificate for all browsers and not all browsers load pages optimally. For those who do not mind that retrieves content first and then to the pictures and videos is a solution. They sleep time may be different than a few seconds, but even a small delay in the user plays the role almost nothing know.Viewers have no problem with delayed loading of images and videos. I had the opportunity to try it and it might be hard to imagine.
Сообщить модератору   Записан
mirny
Пользователь
**

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

Сообщений: 84


« Ответ #8 : 24 декабря 2012, 09:43:19 »

Do you understand that
> unificate for all browsers
will involve reimplementing a large piece of browser's inner logic in an environment that hardly was meant for that?
If so then good luck, go on.
Сообщить модератору   Записан
truefriend-cz
Постоялец
***

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

Сообщений: 118


« Ответ #9 : 24 декабря 2012, 14:51:31 »

Do you understand that
> unificate for all browsers
will involve reimplementing a large piece of browser's inner logic in an environment that hardly was meant for that?
If so then good luck, go on.
Unified for all browsers.
I think it may be hard for help HandyCache Extension.
Would someone please help me this Extension?
Posted on: 2012-12-24, 14:47:31

Idea is create one, or many Extension for analyze filetype and this delay with sleep command for loading from the internet.
One extension for images, second for flash, etc.
It may not work depending on time, but need to load all html, js, css loaded with pictures. Once loaded all pictures will load flash elements.

How to differentiate the content file type in the Extensions? (We do scripts or to argue? If built similar artists like you on the issue of load balancing, shaping and other things they would probably never anything like this started.)
Remember that when you create program so this is used routinely. When traveling by car, you also need to stop occasionally. etc etc. The conditions are not always optimal for smooth operations but it should any operations manage.
I can not help it that I had met a group of people who are either lazy or does not know this. I solve this technical problem. If you have problems you should consult outside. I'm not in the mood for this.
« Последнее редактирование: 24 декабря 2012, 15:28:10 от truefriendcz » Сообщить модератору   Записан
Anymore
Beta tester
*****

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

Сообщений: 339


« Ответ #10 : 24 декабря 2012, 18:14:02 »

What is your internet speed?
Сообщить модератору   Записан
truefriend-cz
Постоялец
***

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

Сообщений: 118


« Ответ #11 : 24 декабря 2012, 19:50:49 »

What is your internet speed?

Provider set limit from 5Mbit to 30kbit - this extension for reading html and images and flashes no not so important. Now loading html, images and flashes suddenly and lasts several times longer. In Mikrotik router can mangle file type and reduce this of speed loading or disable. It works. But I think that it is better that content just pause and loaded later than the rule on and off manually.

Alternative mobile internet (5Mbit) with FUP size MB - this extension for saving mobile data.
« Последнее редактирование: 24 декабря 2012, 20:11:43 от truefriendcz » Сообщить модератору   Записан
Михаил
Gold beta tester
*****

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

Сообщений: 5513



« Ответ #12 : 24 декабря 2012, 21:05:56 »

May be you wanna do smth like this?:

Код:
--[[ <HCExtension>
@name         Delay limit for filetype access by URL
@rule           \.(bmp|jpg|jpeg|png|svgz|swf|tiff|wmf)$
@event         RequestHeaderReceived/Request
</HCExtension> ]]

function Request()
  hc.sleep(10000)
end
Сообщить модератору   Записан
Anymore
Beta tester
*****

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

Сообщений: 339


« Ответ #13 : 25 декабря 2012, 00:06:22 »

Provider set limit from 5Mbit to 30kbit ... Alternative mobile internet (5Mbit) with FUP size MB
give a link to the price list

In Mikrotik router can mangle file type and reduce this of speed loading or disable. It works.
But I think that it is better that content just pause and loaded later than the rule on and off manually.
set firewall on maximum paranoia
try download hyperpool-proxy and configure http://hyperpool.narod.ru/en/tutorial/1-10.html
Сообщить модератору   Записан
reges007
Новичок
*

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

Сообщений: 29


« Ответ #14 : 25 декабря 2012, 00:41:50 »

i think handycache not yet support traffic priority by file type even do extension is impossible
in hcext manual just support speed limit by users or file type not priority speed

if using hc.sleep(xxxx) is just delay proses to download and it does not solve the problem when using internet sharing
because if the download (hc.sleep) is running when her time then other processes (html,etc...) will be disturbed

sorry if my opinion is wrong and for my bad english...
Сообщить модератору   Записан
truefriend-cz
Постоялец
***

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

Сообщений: 118


« Ответ #15 : 25 декабря 2012, 02:43:57 »

give a link to the price list
set firewall on maximum paranoia
try download hyperpool-proxy and configure http://hyperpool.narod.ru/en/tutorial/1-10.html
1. 20€/Month ISP on Wifi connection, 3€/Month Mobile Internet
1b. firewall can not have function for delay loading packets, or mangle rules (Mikrotik and Cisco is best, but this can not)
2. no thank HC comes to me ok as sufficient and do not need based sw on additional support sw as Python, Java, etc.
Posted on: 2012-12-25, 02:30:42

May be you wanna do smth like this?:
...
Yes. THANK YOU VERY MUCH Михаил for this. I edit script and first version is:

Код:
--[[ <HCExtension>
@name          Delay limit for filetype access by URL
@event         RequestHeaderReceived/Request
@event         AnswerHeaderReceived/Answer
</HCExtension> ]]


function GetContentType(s)
  _,_,x = string.find(s, '[cC]ontent%-[tT]ype: *([^;\r\n]+)')
  if x~=nil then x = string.lower(x) end
  return x
end


function Request()
  if re.find(hc.url, [[^[^?]+\.(bmp|jpg|jpeg|png|svgz|swf|tiff|wmf)(\?|$)]], 0) then
    hc.sleep(1000)
    hc.monitor_string = hc.monitor_string..'Ext-Image '
  end
end


function Answer()
  if hc.method == 'GET' then
    type = GetContentType(hc.answer_header)
    if type~=nil then img = string.find(type,'image',1,true)
    else img = nil  end
      if img~=nil then
        hc.sleep(1000)
        hc.monitor_string = hc.monitor_string..'Ext-Image '
      end
  end
end

It works perfect but i have a problem that this script applies to files that are in the cache.
How i can edit the script for: if files exist in cache = no sleep?
« Последнее редактирование: 25 декабря 2012, 03:19:59 от truefriendcz » Сообщить модератору   Записан
Anymore
Beta tester
*****

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

Сообщений: 339


« Ответ #16 : 25 декабря 2012, 03:29:17 »

   
first thing delete event RequestHeaderReceived and function Request
Сообщить модератору   Записан
truefriend-cz
Постоялец
***

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

Сообщений: 118


« Ответ #17 : 25 декабря 2012, 04:40:40 »

No better this?
Код:
--[[ <HCExtension>
@name          Delay limit for filetype access by URL (image)
@event         RequestHeaderReceived/Request
@event         AnswerHeaderReceived/Answer
</HCExtension> ]]


function GetContentType(s)
  _,_,x = string.find(s, '[cC]ontent%-[tT]ype: *([^;\r\n]+)')
  if x~=nil then x = string.lower(x) end
  return x
end

function Request()
  if re.find(hc.url, [[^[^?]+\.(ani|bmp|cal|fax|gif|img|jbg|jpe|jpeg|jpg|mac|pbm|pcd|pcx|pct|pgm|png|ppm|psd|ras|tga|tiff|wmf)(\?|$)]], 0) then
    if hc.cache_file_name== '' then
      hc.sleep(2000)
      hc.monitor_string = hc.monitor_string..'Ext-Image '
    end
  end
end

function Answer()
  if hc.method == 'GET' then
    type = GetContentType(hc.answer_header)
    if type~=nil then img = string.find(type,'image',1,true)
    else img = nil  end
      if img~=nil then
        if hc.cache_file_name== '' then
          hc.sleep(2000)
          hc.monitor_string = hc.monitor_string..'Ext-Image '
        end
      end
  end
end
Сообщить модератору   Записан
Михаил
Gold beta tester
*****

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

Сообщений: 5513



« Ответ #18 : 25 декабря 2012, 07:21:12 »

Цитировать
How i can edit the script for: if files exist in cache = no sleep?
Use BeforeRequestHeaderSend instead of RequestHeaderReceived.
Сообщить модератору   Записан
mirny
Пользователь
**

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

Сообщений: 84


« Ответ #19 : 25 декабря 2012, 07:53:11 »

truefriendcz, nesting ifs is lame, mang. Use and instead.
Код:
if img~=nil and hc.cache_file_name== '' then
  hc.sleep(2000)
  hc.monitor_string = hc.monitor_string..'Ext-Image '
end
Сообщить модератору   Записан
Страниц: [1] 2  Все   Вверх
  Отправить эту тему    Печать  

 
Перейти в: