Skip to content

Instantly share code, notes, and snippets.

View RatJantaraksa's full-sized avatar

RAT JANTARAKSA RatJantaraksa

  • Bangkok
View GitHub Profile
$posts = Cache::remember('index.posts', 30, function(){
return Post::with('comments', 'tags', 'author', 'seo')->whereHidden(0)->get();
});
// 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
## 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