My Octopress Blog

A blogging framework for hackers.

ทำ Cache ให้ Traffy API [Proxy/Wrapper] แล้วจ้า (Drupal7)

ผลจากการทำ cache ทำให้เวลาในการเรียกใช้ api getcctvimg เฉลี่ยอยู่ที่ประมาณ 2.53 วินาที [มาจาก 2.58 2.77 2.52 2.28] ถ้าไม่ cache เวลาเฉลี่ยจะประมาณ 6.1825 [มาจาก (8.91+6.20+4.06+5.56)/4]

ภาพประกอบการทดลอง

ภาพข้างล่าง: แสดงเวลาแบบไม่ cache จ้า

getcctvimg (400ճ00) 8.92 nocache

### ภาพข้างล่าง: แสดงเวลาแบบ cache จ้า <div class=”thumbnail”>getcctvimg (400ճ00) 2.49 cache</div>

api ที่มี cache

  • getcctv – 5 นาที
  • getcctvimg – 5 นาที

ข้อยกเว้น

  • ไม่ cache ข้อมูลชนิด ?&format=js
  • ไม่ใช้ cache เมื่อมี ?&nocache=1

ทดลองใช้

  • แบบมี cache

http://www.together.in.th/drupal/traffy/wrapper/getcctvimg?format=jpeg&id=268&header=jpeg

  • แบบไม่เอา cache

http://www.together.in.th/drupal/traffy/wrapper/getcctvimg?format=jpeg&id=268&header=jpeg&nocache=1