Coder Social home page Coder Social logo

kirby-fingerprint's Introduction

Fingerprint for Kirby 2

What is it?

The Fingerprint plugin adds fingerprints to css and js filenames based on their contents.

Why use it?

As the fingerprint on the file changes after the contents of the file have been changed it will help you bust the browsercache.

How to use it?

Add it using git: git submodule add https://github.com/iksi/kirby-fingerprint.git site/plugins/kirby-fingerprint or do it manually by downloading the repository, renaming the folder to kirby-fingerprint and placing it in /site/plugins. You can use the normal Kirby css() and js() helper functions.

Add the following lines to your htaccess file (after RewriteBase):

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)-([0-9a-z]+)\.(js|css)$ $1.$3 [L]

Or for Nginx you can add the following to your virtual host setup:

location /assets {
    if (!-e $request_filename) {
        rewrite "^/(.+)-([0-9a-z]+)\.(js|css)$" /$1.$3 break;
    }
}

Enable fingerprinting by adding the following to you config.php file:

c::set('plugin.fingerprint', true);
c::set('plugin.fingerprint.trim', 20);
c::set('plugin.fingerprint.algorithm', 'md5');

You can also use Kirby’s @auto for autoloading and fingerprinting template specific assets.

External urls

External urls won’t be fingerprinted.

Author

Jurriaan Topper [email protected] (http://www.iksi.eu/)

kirby-fingerprint's People

Contributors

daybugging avatar ericcholis avatar iksi avatar minimalweb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

kirby-fingerprint's Issues

@auto does not fingerprint

if you do template specific css or js with the kirby helper @auto, fingerprint does not work.

For example, js(fingerprint('@auto')) or css(fingerprint('@auto')) pulls the file without the fingerprint.

Problem with rewrite engine

Hello, i just tried your plugin and i have a little problem.
The code i used is this :

<!--  <?php echo css('assets/css/main.css') ?>-->
  <?php echo cssfingerprint('assets/css/main.css') ?>

And what i get :

<!--  <link rel="stylesheet" href="http://192.168.0.10/dev/pro/ad62/assets/css/main.css">-->
  <link rel="stylesheet" href="http://192.168.0.10/dev/pro/ad62/assets/css\main.7eb9c8dbba117ab1727e7ef47a65b3d5.css">

The "" just before the main is a problem i think, what can i do?

Edit : it seems to work in production so it's a local problem. I use xammp, do you have an idea about this?

fingerprinting and gzip

i am using the following deflate/gzip setup but yslow tells me fingerprinted js is not compressed. any ideas?

# BEGIN GZIP
# mod_gzip compression (legacy, Apache 1.3)
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|xml|txt|css|js)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>
# END GZIP

# DEFLATE compression
<IfModule mod_deflate.c>
# Set compression for: html,txt,xml,js,css
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript
# Deactivate compression for buggy browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
# Set header information for proxies
Header append Vary User-Agent
</IfModule>
# END DEFLATE

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.