Mov­ing files to a new loca­tion may appear straight­for­ward, but when con­sid­er­ing the impact on your site’s SEO per­for­mance, it becomes a del­i­cate and time-sen­si­tive task. This is espe­cial­ly true when deal­ing with files host­ed on an exter­nal ser­vice such as AWS S3.

Here are a cou­ple of pos­si­ble sce­nar­ios by clients’ requests:

  • Mod­i­fy file URIs, adding or remov­ing slugs
  • Pro­gram­mat­i­cal­ly rename files based on their par­ent names (our case)
  • Imple­ment changes relat­ed to the domain

When the files are host­ed on your own serv­er through your CMS, such as Craft or Dru­pal, you have the option to uti­lize plu­g­ins or mod­ules to cre­ate 301 redi­rects (per­ma­nent­ly moved) and mon­i­tor any bro­ken links that end users might encounter.

In this par­tic­u­lar case study, the client has their files stored in an AWS S3 buck­et and using a Cloud­Front dis­tri­b­u­tion. We explored two poten­tial solu­tions: AWS Lambda@Edge Func­tions and Cloud­Front Functions.

Cloud­Front Func­tions #

Pros:

  • Fast Response
  • Cheap­er, it has a free tier available
  • Eas­i­er to set up
  • Eas­i­er to test
  • More intu­itive dashboard

Cons:

  • Lim­it­ed file size
  • Short­er func­tion dura­tion (time­out: with­in milliseconds)
  • Javascript-based

Lambda@Edge Func­tions #

Pros:

  • Pos­si­ble to have mul­ti­ple files
  • JSON files are an option
  • Mul­ti­ple Lan­guages avail­able (Node.js, .NET, Python, Java, Ruby)
  • Pos­si­ble to have larg­er functions

Cons:

  • Dash­board is tricky 
  • You need to con­nect the func­tion with CloudFront
  • More Expen­sive: Charged per request ($0.60 USD per 1 mil­lion requests)

We start­ed with Cloud­Front Func­tions but had to move to Lambda@Edge Func­tions because of the file size lim­it of Cloud­Front Functions.

Cloud­Front Func­tion Sam­ple using Javascript.

Lambda@Edge Func­tions Sam­ple using Javascript and JSON.

Keep into con­sid­er­a­tion the pros and cons for your spe­cif­ic needs and vis­it 301 redi­rects for files host­ed in Ama­zon S3 using Cloud­Front Func­tions or 301 redi­rects for files host­ed in Ama­zon S3 using Lambda@Edge Func­tions to get started.

If you have any ques­tions, feel free to con­tact me.


Claudia Aguilar

Partner, Software Engineer