วิธีการเพิ่มความเร็วให้ squid

วิธีการเพิ่มความเร็วให้ squid
1. เปิด winscp แล้วเข้าไปที่  /etc/squid/
2. คลิ๊กขวาที่ไฟล์ที่ชื่อ squid.conf.tmpl แล้วเลือก Edit
3. หลังจากที่โปรแกรมเปิดไฟล์ขึ้นมาให้ไปเพิ่มคำสั่งตามรายการข้างล่างนี้  ไปที่ส่วนท้ายของไฟล์
——————————————————————————————–
refresh_pattern -i .art$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .crw$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .djvu$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .ttf$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .fpx$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .icn$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .ico$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .icl$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .kdc$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .mag$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .sif$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .aifc$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .aiff$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .asf$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .au$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .avi$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .m1v$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .mid$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .midi$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .mp2$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .mp2v$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .mp3$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .mpa$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .mpe$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .mpeg$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .mpg$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .mpv2$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .rmi$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .snd$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .wav$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .wma$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .wmv$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .sid$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .pcd$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .pic$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .pict$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .pix$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .pbm$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .pgm$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .ppm$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .eps$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .psp$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .xbm$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .xpm$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .bmp$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .jpeg$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .pcx$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .png$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .tga$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .tiff$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .gif$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .wmf$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .emf$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .pic$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .iff$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .psd$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .ras$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .rs$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .sgi$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .swf$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .pdf$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .exe$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .zip$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .rar$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .mov$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .cda$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .mp1$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .aac$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .nsa$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .ogg$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .kar$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .miz$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .mod$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .mdz$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .nst$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .stm$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .stz$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .s3m$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .s3z$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .it$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .itz$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .xm$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .xmz$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .mtm$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .ult$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .669$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .far$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .amf$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .okt$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .ptm$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .voc$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .aif$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .m2v$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .nsv$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .m3u$ 525960 80% 525960 reload-into-ims
refresh_pattern -i .pls$ 525960 80% 525960 reload-into-ims
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320
———————————————————————————————–

4. กดปุ่ม save หรือ ctrl+s
5. เข้าหน้าเว็ปไปเปิดปิดตัว Squid proxy ใหม่
6. จากนั้นให้รีสตาร์ทตัวไฟล์วอร์แล้วแจ้งผลหน่อยครับว่า เปิดเว็บเร็วขึ้นไหม

ข้อมูลอ้างอิงจากเว็บ http://star-internet.com/SMF115/index.php?topic=74.0 เพื่อให้ข้อมูลต่อเนื่องกัน

refresh pattern เป็นตัวกำหนดว่าจะให้อะไรเก่าอะไรใหม่สำหรับแคชและการตอบกลับ ซึ่งโดยหลักการแล้ว คุณควรจะให้ squid เชื่อตาม HTTP header ต่าง ๆ ที่เว็บเซิร์ฟเวอร์ตอบกลับมา ว่าอะไรเก่าอะไรใหม่ขนาดไหน แต่โชคไม่ดีที่ค่าต่าง ๆ เหล่านี้มักตอบมาตามค่า default ของเว็บเซิร์ฟเวอร์ ซึ่งไม่ช่วยอะไรนักสำหรับการทำแคช ดังนั้น การปรับ refresh pattern จึงช่วยได้ในเรื่องนี้

refresh pattern ใน squid.conf จะอยู่ในรูปแบบ:

refresh_pattern [-i] regex min percent max [options]
โดยที่

regex คือนิพจน์เรกิวลาร์แทน URL ที่จะเข้ากฎ โดยปกติจะ case sensitive ยกเว้นเมื่อมีตัวเลือก -i
min คืออายุที่ต่ำที่สุด (เป็นนาที) ของอ็อบเจกต์ที่จะเริ่มพิจารณาความเก่าใหม่ โดยถ้าต่ำกว่านี้จะถือว่าใหม่เสมอ (ยกเว้นว่ามีการกำหนดเวลาหมดอายุมาใน HTTP header)
max คืออายุที่สูงที่สุด (เป็นนาที) ของอ็อบเจกต์ที่จะยังคงพิจารณาความเก่าใหม่อยู่ โดยถ้าสูงกว่านี้จะถือว่าเก่าเสมอ
percent คือเปอร์เซ็นต์ของอายุในแคชของอ็อบเจกต์นับตั้งแต่ refresh ครั้งล่าสุด เทียบกับอายุจริงของอ็อบเจกต์ตามที่เว็บเซิร์ฟเวอร์รายงาน ที่จะยังคงถือว่าอ็อบเจกต์นั้นยังใหม่อยู่
options คือตัวเลือกเพิ่มเติม ซึ่งจะกล่าวถึงในภายหลัง
ตัวอย่างเช่น

refresh_pattern -i .gif$ 1440 20% 10080
หมายความว่า:

ถ้าอ็อบเจกต์ *.gif มี header ระบุเวลาหมดอายุ ก็เชื่อถือตาม header นั้น จบ ถ้าไม่มี จึงพิจารณาต่อไป
ถ้าอ็อบเจกต์อยู่ในแคชต่ำกว่า 1440 นาที (1 วัน) ถือว่ายังใหม่อยู่ ใช้ค่าในแคชตอบกลับได้ทันที
ถ้าอ็อบเจกต์อยู่ในแคชมานานเกิน 10080 นาที (7 วัน) ถือว่าเก่าแล้ว ให้ดึงอ็อบเจกต์มาใหม่จากเว็บเซิร์ฟเวอร์
ถ้า อายุในแคชของอ็อบเจกต์อยู่ระหว่าง 1440-10080 นาที ให้พิจารณาอายุในแคช ว่าถึง 20% ของอายุจริงหรือไม่ เช่น ถ้าเว็บเซิร์ฟเวอร์รายงานมาว่าอ็อบเจกต์นี้สร้างขึ้นเมื่อ 10,000 นาทีที่แล้ว ก็พิจารณาว่าอ็อบเจกต์อยู่ในแคชมานานถึง 20% ของ 10,000 คือ 2,000 นาทีหรือไม่ ถ้ายังไม่ถึง ก็ถือว่ายังใหม่ ถ้าถึง ก็ถือว่าเก่าแล้ว
ส่วน options หรือตัวเลือกเพิ่มเติม ส่วนใหญ่จะเป็นการพยายามละเมิดมาตรฐาน HTML เพื่อเพิ่มอัตราการแคช จึงควรระมัดระวังในการใช้งาน ตัวเลือกมีดังนี้:

override-expire — ไม่ต้องสนใจ header ระบุเวลาหมดอายุที่เว็บเซิร์ฟเวอร์บอกมา (พิจารณาตามกฎเสมอ)
override-lastmod — ไม่สนใจ header ระบุเวลาเปลี่ยนแปลงล่าสุดที่เว็บเซิร์ฟเวอร์บอกมา (ถือว่าอ็อบเจกต์มีอายุจริงเท่ากับ min แม้จะเพิ่งเปลี่ยนแปลงใหม่)
reload-into-ims — เปลี่ยน request “no-cache” จากลูกข่ายให้เป็น If-Modified-Since
ignore-reload — ไม่สนใจ header “no-cache” จากลูกข่าย และจะใช้ข้อมูลในแคชถ้าทำได้
ignore-no-cache — ไม่สนใจ header “Pragma: no-cache” และ “Cache-control: no-cache” ที่ส่งมาจากเว็บเซิร์ฟเวอร์ ซึ่ง HTTP RFC ไม่ได้อนุญาตให้เว็บเซิร์ฟเวอร์ทำ แต่ก็มักจะทำกัน
ignore-no-store — ไม่สนใจ header “Cache-control: no-store” ที่ส่งมาจากเว็บเซิร์ฟเวอร์
ignore-private — ไม่สนใจ header “Cache-control: private” ที่ส่งมาจากเว็บเซิร์ฟเวอร์
ignore-auth — เก็บอ็อบเจกต์ที่ต้องผ่านการยืนยันตัวบุคคลของผู้อ่านลงแคชด้วย
refresh-ims — ส่ง request If-Modified-Since ไปที่เว็บเซิร์ฟเวอร์เมื่อผู้ใช้ refresh หน้าเว็บ
คุณ สามารถปรับ refresh pattern ให้เก็บอ็อบเจกต์ที่มักไม่มีการเปลี่ยนแปลง เช่น รูปภาพ เสียง วีดิทัศน์ แฟ้มโปรแกรม แฟ้มบีบอัด ฯลฯ ให้อยู่ในแคชนานขึ้นได้ เพื่อเพิ่มอัตราการ hit เช่น (คัดลอกมาจากบทความต้นตอ):

refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i .(gif|png|jpg|jpeg|ico)$
  10080 90% 43200 override-expire ignore-no-cache ignore-no-store ignore-private
refresh_pattern -i .(iso|avi|wav|mp3|mp4|mpeg|swf|flv|x-flv)$
  43200 90% 432000 override-expire ignore-no-cache ignore-no-store ignore-private
refresh_pattern -i .(deb|rpm|exe|zip|tar|tgz|ram|rar|bin|ppt|doc|tiff)$  
  10080 90% 43200 override-expire ignore-no-cache ignore-no-store ignore-private
refresh_pattern -i .index.(html|htm)$ 0 40% 10080
refresh_pattern -i .(html|htm|css|js)$ 1440 40% 40320
refresh_pattern . 0 40% 40320
กฎ จะถูกนำมาตรวจสอบเรียงทีละกฎจากบนลงล่าง จนกว่าจะพบกฎแรกที่ตรง ก็จะใช้กฎนั้นและหยุดตรวจสอบต่อ ดังนั้น กฎสุดท้ายจึงเป็นกฎที่เอาไว้รองรับแพตเทิร์นที่เหลือโดยทั่วไป และมักจะแยกกฎสำหรับโพรโทคอลอื่นอย่างเช่น FTP และ gopher เอาไว้บนสุด เพื่อกันไม่ให้มาใช้กฎด้านล่าง

Credit http://www2.thaiadmin.org/board/index.php?topic=109053.0

แก้ Endian 2.5 เน็ตช้า

    nano /usr/lib/efw/dansguardian/default/settings
    แก้ไขในส่วนของ

    MAXCHILDREN=500
    MINCHILDREN=128
    MINSPARECHILDREN=32
    PREFORKCHILDREN=16
    MAXSPARECHILDREN=256
    MAXAGECHILDREN=10000

    และ
    nano /var/efw/havp/settings
    แก้ไขในส่วนของ
    MAXSERVERS=150
    SERVERNUMBER=50

Bug tracker http://bugs.endian.com/view.php?id=4350