George Mason University Antonin Scalia Law School

Speed Up Site Performance

Set HTTP Cache Headers

<VirtualHost *:80>
# Your config...
ExpiresActive On
<FilesMatch "\.(ico|gif|jpe?g|png|js|css)$">
ExpiresDefault "access plus 1 year"
Header unset ETag
FileETag None
Header unset Last-Modified
</FilesMatch>
</VirtualHost>

Gzip Web Server Output

<VirtualHost *:80>
# Your config...
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \\bMSIE !no-gzip !gzip-only-text/html
</VirtualHost>

Source: Faster Sites Done Faster

Further reading: Using a far future expires header

Change Server Upload Permissions

  1. Enter ssh username@mason.gmu.edu replacing username appropriately.
  2. Enter your mason.gmu.edu password
  3. mason> pico .cshrc
  4. edit to reads umask 022 or umask 002 (If other people in your group edit the website, change your umask to 002; If only you edit your website, change it to 022)
  5. Save the file (Ctrl+O) (letter O)
  6. File Name to write: .cshrc will display towards the bottom of the window. Hit enter.
  7. Exit the file (Ctrl+X).
  8. Run pico .profile and pico .login and repeat Steps 3 and 4.
  9. Log out and then log back in again.

Source: Fix Server Upload Permissions

Roll Your Own Social Media Buttons

I recently tested out several WordPress’s social media share plug-ins and disappointed with unnecessary injections of JavaScripts and CSS. Some services even use their own site as a gateway to server up the social media services. I was frustrated and ended up rolling my own, thanks to this blog post. Here’s my customized codes:

<a href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t=<?php the_title(); ?>" target="_blank"><img src="facebook.png" alt="Share on Facebook"></a>

<a href=”https://plusone.google.com/_/+1/confirm?hl=en-US&url=<?php the_permalink() ?>” target=”_blank”><img src=”google-plus.png” alt=”Share on Google+”></a>

<a href=”http://twitter.com/share?text=<?php the_title(); ?> -&url=<?php the_permalink() ?>” target=”_blank”><img src=”twitter.png” alt=”Share on Twitter”></a>

<a href=”http://www.linkedin.com/shareArticle?mini=true&url=<?php the_permalink() ?>” target=”_blank”><img src=”linkedin.png” alt=”Share on LinkedIn”></a>

Sass

$ sass --watch style.scss:style.css --style compressed

// Import
@import "normalize";

// Variables
$body_font: 'Georgia', serif;

// Mixin
@mixin rounded_corners($rounding) {
-webkit-border-radius:$rounding;
-moz-border-radius: $rounding;
-o-border-radius: $rounding;
border-radius: $rounding; }

Apache Rewrites

Redirect non-www to www with .htaccess


RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Example: law.gmu.edu to www.law.gmu.edu


Add trailing slash (/) to URL:


RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.sample.com/$1/ [QSA,L,R=301]

Example: law.gmu.edu to law.gmu.edu/