+  HandyCache форум
|-+  Главная категория» English forum» Small Media Files
Имя пользователя:
Пароль:
Страниц: [1]   Вниз
  Отправить эту тему    Печать  
Автор Тема: Small Media Files  (Прочитано 5141 раз)
0 Пользователей и 1 Гость смотрят эту тему.
pankaj17939
Новичок
*

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

Сообщений: 43


« : 11 февраля 2013, 13:17:17 »

I want to block small images files from caching on disk, I had edited the script it, but it is not working.
Please guide...

--[[ <HCExtension>
@name          Block File < 1 kb Img or Vid
@author        ABCD
@version       1.1 HC v1.00 RC2 (1.0.0.175)
@description   Stop cache file size Smaller then 1 KB Image and video
@event         AnswerHeaderReceived/Answer
</HCExtension> ]]

function GetContentLength(s)
  _,_,x = string.find(s, '[cC]ontent%-[lL]ength: *(%d+)')
  if x==nil then return -1 else return tonumber(x) end
end

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

function Answer()

 -- Method GET
 -- if hc.method == 'GET' then

   -- 'Content-Length'
    len = GetContentLength(hc.answer_header)

   -- 'Content-Type'
    type = GetContentType(hc.answer_header)

   -- Check 'Content-Type' is 'image'
    if type~=nil then img = string.find(type,'image',1,true)
    else img = nil  end

   -- Check 'Content-Type' is 'video'
    if type~=nil then vid = string.find(type,'video',1,true)
    else vid = nil  end

   -- Check 'Content-Type' is 'Audio'
    if type~=nil then aud = string.find(type,'audio',1,true)
    else aud = nil  end

   -- Check type is image or video or Audio'
    if img~=nil or vid~=nil or aud~=nil then act = 1
    else act = nil  end


   -- .25 mb  that is 256kb
   -- if len < 500  and act~= nil  then
    if len < 25  and act~= nil  then
   
      if hc.action=='' or hc.action==nil or hc.action=='save' then
        hc.action = 'save-'
        hc.monitor_string = hc.monitor_string..'Small Media File'
      end
   
    end

--  end

end  --  Answer

Сообщить модератору   Записан
DenZzz
Модератор
*****

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

Сообщений: 5589



« Ответ #1 : 11 февраля 2013, 22:37:53 »

        hc.action = 'save-'

If you don't want to save the file, then write like this:
Код:
  hc.action = 'dont_save'
Сообщить модератору   Записан
LordMerlin
Старожил
****

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

Сообщений: 488


« Ответ #2 : 12 февраля 2013, 09:37:57 »

It's easy as you mind.
Go to HC "Options" - "Cache-Control" - "Save to cache" block.
And enable options "Dont save files smaller than"
Сообщить модератору   Записан
pankaj17939
Новичок
*

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

Сообщений: 43


« Ответ #3 : 16 февраля 2013, 12:58:44 »

Thanks
Сообщить модератору   Записан
Страниц: [1]   Вверх
  Отправить эту тему    Печать  

 
Перейти в: