Skip to content

Instantly share code, notes, and snippets.

Avatar

RAT JANTARAKSA RatJantaraksa

  • Bangkok
View GitHub Profile
View Mod Expires
## EXPIRES HEADER CACHING ##
<IfModule mod_expires.c>
# Fonts
# Add correct content-type for fonts
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-ttf .ttf
AddType application/x-font-opentype .otf
AddType application/x-font-woff .woff
AddType image/svg+xml .svg
ExpiresActive On
View eager_loading.php
// Lazy Loading N+1 Query
$books = App\Book::all();
foreach ($books as $book) {
echo $book->author->name;
}
// select * from books
// select * from authors where id = 1
// select * from authors where id = N
View cache_queries.php
$posts = Cache::remember('index.posts', 30, function(){
return Post::with('comments', 'tags', 'author', 'seo')->whereHidden(0)->get();
});
You can’t perform that action at this time.